pb-sxp-ui 1.16.17 → 1.16.19

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.
@@ -13,10 +13,10 @@ const LikeButton = (_a) => {
13
13
  const likeIcon = useIconLink(defaultLikeIconPath);
14
14
  const unlikeIcon = useIconLink(defaultUnLikeIconPath);
15
15
  const handleClick = debounce(() => __awaiter(void 0, void 0, void 0, function* () {
16
- var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5;
16
+ var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7;
17
17
  if (state) {
18
18
  setState(false);
19
- const result = (_e = (yield (mutateUnlike === null || mutateUnlike === void 0 ? void 0 : mutateUnlike({ videoItemId: (_d = (_c = recData === null || recData === void 0 ? void 0 : recData.video) === null || _c === void 0 ? void 0 : _c.itemId) !== null && _d !== void 0 ? _d : '' })))) !== null && _e !== void 0 ? _e : false;
19
+ const result = (_e = (yield (mutateUnlike === null || mutateUnlike === void 0 ? void 0 : mutateUnlike({ itemId: (_d = (_c = recData === null || recData === void 0 ? void 0 : recData.video) === null || _c === void 0 ? void 0 : _c.itemId) !== null && _d !== void 0 ? _d : '' })))) !== null && _e !== void 0 ? _e : false;
20
20
  bffEventReport === null || bffEventReport === void 0 ? void 0 : bffEventReport({
21
21
  eventInfo: {
22
22
  eventSubject: 'favoriteContentCanceled',
@@ -45,30 +45,30 @@ const LikeButton = (_a) => {
45
45
  }
46
46
  else {
47
47
  setState(true);
48
- const result = (_t = (yield (mutateLike === null || mutateLike === void 0 ? void 0 : mutateLike({ content: JSON.stringify(recData) })))) !== null && _t !== void 0 ? _t : false;
48
+ const result = (_v = (yield (mutateLike === null || mutateLike === void 0 ? void 0 : mutateLike({ content: JSON.stringify(recData), itemId: (_u = (_t = recData === null || recData === void 0 ? void 0 : recData.video) === null || _t === void 0 ? void 0 : _t.itemId) !== null && _u !== void 0 ? _u : '' })))) !== null && _v !== void 0 ? _v : false;
49
49
  bffEventReport === null || bffEventReport === void 0 ? void 0 : bffEventReport({
50
50
  eventInfo: {
51
51
  eventSubject: 'favoriteContent',
52
52
  eventDescription: 'This content was favorite by the user',
53
- contentId: (_v = (_u = recData === null || recData === void 0 ? void 0 : recData.video) === null || _u === void 0 ? void 0 : _u.itemId) !== null && _v !== void 0 ? _v : '',
54
- sceneId: (_y = (_x = (_w = recData === null || recData === void 0 ? void 0 : recData.video) === null || _w === void 0 ? void 0 : _w.scene) === null || _x === void 0 ? void 0 : _x.sceneId) !== null && _y !== void 0 ? _y : '',
55
- contentName: (_0 = (_z = recData === null || recData === void 0 ? void 0 : recData.video) === null || _z === void 0 ? void 0 : _z.title) !== null && _0 !== void 0 ? _0 : '',
56
- contentTags: JSON.stringify((_2 = (_1 = recData === null || recData === void 0 ? void 0 : recData.video) === null || _1 === void 0 ? void 0 : _1.tags) !== null && _2 !== void 0 ? _2 : []),
53
+ contentId: (_x = (_w = recData === null || recData === void 0 ? void 0 : recData.video) === null || _w === void 0 ? void 0 : _w.itemId) !== null && _x !== void 0 ? _x : '',
54
+ sceneId: (_0 = (_z = (_y = recData === null || recData === void 0 ? void 0 : recData.video) === null || _y === void 0 ? void 0 : _y.scene) === null || _z === void 0 ? void 0 : _z.sceneId) !== null && _0 !== void 0 ? _0 : '',
55
+ contentName: (_2 = (_1 = recData === null || recData === void 0 ? void 0 : recData.video) === null || _1 === void 0 ? void 0 : _1.title) !== null && _2 !== void 0 ? _2 : '',
56
+ contentTags: JSON.stringify((_4 = (_3 = recData === null || recData === void 0 ? void 0 : recData.video) === null || _3 === void 0 ? void 0 : _3.tags) !== null && _4 !== void 0 ? _4 : []),
57
57
  position: position + '',
58
- contentFormat: ((_3 = recData === null || recData === void 0 ? void 0 : recData.video) === null || _3 === void 0 ? void 0 : _3.url) ? 'video' : 'image',
59
- traceInfo: (_4 = recData === null || recData === void 0 ? void 0 : recData.video) === null || _4 === void 0 ? void 0 : _4.traceInfo
58
+ contentFormat: ((_5 = recData === null || recData === void 0 ? void 0 : recData.video) === null || _5 === void 0 ? void 0 : _5.url) ? 'video' : 'image',
59
+ traceInfo: (_6 = recData === null || recData === void 0 ? void 0 : recData.video) === null || _6 === void 0 ? void 0 : _6.traceInfo
60
60
  }
61
61
  });
62
62
  if (!result) {
63
63
  setState(false);
64
64
  }
65
65
  else {
66
- const nRtcList = (_5 = cacheRtcList === null || cacheRtcList === void 0 ? void 0 : cacheRtcList.map((item, index) => {
66
+ const nRtcList = (_7 = cacheRtcList === null || cacheRtcList === void 0 ? void 0 : cacheRtcList.map((item, index) => {
67
67
  if (index === position) {
68
68
  item.isCollected = true;
69
69
  }
70
70
  return item;
71
- })) !== null && _5 !== void 0 ? _5 : [];
71
+ })) !== null && _7 !== void 0 ? _7 : [];
72
72
  setCacheRtcList === null || setCacheRtcList === void 0 ? void 0 : setCacheRtcList(nRtcList);
73
73
  }
74
74
  }
@@ -21,12 +21,8 @@ export interface ISxpDataSourceContext {
21
21
  value: string;
22
22
  }>;
23
23
  }) => Promise<boolean | undefined>;
24
- mutateUnlike?: (body: {
25
- videoItemId: string;
26
- }) => Promise<boolean>;
27
- mutateLike?: (body: {
28
- content: string;
29
- }) => Promise<boolean>;
24
+ mutateUnlike?: (body: Record<string, any>) => Promise<boolean>;
25
+ mutateLike?: (body: Record<string, any>) => Promise<boolean>;
30
26
  popupDetailData?: RecItemType;
31
27
  setPopupDetailData?: React.Dispatch<React.SetStateAction<any | null>>;
32
28
  loadVideos?: (page: number) => Promise<RecommendVideoResultType | undefined>;
@@ -107,12 +103,8 @@ export interface SxpDataSourceProviderProps {
107
103
  value: string;
108
104
  }>;
109
105
  }) => Promise<boolean | undefined>;
110
- mutateUnlike: (body: {
111
- videoItemId: string;
112
- }) => Promise<boolean>;
113
- mutateLike: (body: {
114
- content: string;
115
- }) => Promise<boolean>;
106
+ mutateUnlike: (body: Record<string, any>) => Promise<boolean>;
107
+ mutateLike: (body: Record<string, any>) => Promise<boolean>;
116
108
  pageData?: PageData;
117
109
  }) => ReactNode;
118
110
  utmVal?: string;
@@ -107,7 +107,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
107
107
  return ((_a = bffDataSource === null || bffDataSource === void 0 ? void 0 : bffDataSource.headers) === null || _a === void 0 ? void 0 : _a['x-app-id']) + storeAndLoadFeUserId();
108
108
  }, [bffDataSource]);
109
109
  const bffFetch = useCallback((path, options, isBota = true) => {
110
- var _a;
110
+ var _a, _b;
111
111
  if (!bffDataSource)
112
112
  return;
113
113
  const url = bffDataSource.url;
@@ -122,9 +122,9 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
122
122
  const value = val.split('=')[1];
123
123
  params[key] = value;
124
124
  });
125
- options.body = Object.assign(Object.assign({}, options.body), { tenant_id: fakeUserId });
125
+ options.body = Object.assign(Object.assign({}, options.body), { productUserId: fakeUserId });
126
126
  return window
127
- .fetch(`${url}/api/${path}`, Object.assign({ headers: Object.assign({ 'Content-Type': 'application/json', 'x-user-id': fakeUserId }, bffDataSource.headers), method: options.method, body: options.type === 'beacon' && isBota
127
+ .fetch(`${url}/api/${path}`, Object.assign({ headers: Object.assign({ 'Content-Type': 'application/json', 'x-user-id': fakeUserId, 'tenant-id': (_b = bffDataSource === null || bffDataSource === void 0 ? void 0 : bffDataSource.headers) === null || _b === void 0 ? void 0 : _b['x-app-id'] }, bffDataSource.headers), method: options.method, body: options.type === 'beacon' && isBota
128
128
  ? JSON.stringify({
129
129
  body: btoa(encodeURIComponent(JSON.stringify(Object.assign(Object.assign(Object.assign({}, options.body), bffDataSource.headers), { 'x-user-id': fakeUserId }))))
130
130
  })
@@ -426,7 +426,9 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
426
426
  return;
427
427
  }
428
428
  if (!userInfo) {
429
- userInfo = {};
429
+ userInfo = {
430
+ productUserId: fakeUserId
431
+ };
430
432
  }
431
433
  const sessionID = storeAndLoadFeSessionId();
432
434
  const params = {};
@@ -459,7 +461,8 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
459
461
  layoutVariantId,
460
462
  globalConfig,
461
463
  playbookType,
462
- bffDataSource
464
+ bffDataSource,
465
+ fakeUserId
463
466
  ]);
464
467
  const getEventParamsByJson = useCallback((json, product) => {
465
468
  var _a, _b, _c;
@@ -589,13 +592,15 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
589
592
  }
590
593
  }, [bffFetch, enableReportEvent, enabledMetaConversionApi, globalConfig, bffDataSource, getEventParamsByJson]);
591
594
  const bffMutateLike = useCallback((body) => __awaiter(void 0, void 0, void 0, function* () {
595
+ body = Object.assign(Object.assign({}, body), { productUserId: fakeUserId });
592
596
  const res = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('v1/recommend/like', { method: 'POST', body }));
593
597
  return res === null || res === void 0 ? void 0 : res.success;
594
- }), [bffFetch]);
598
+ }), [bffFetch, fakeUserId]);
595
599
  const bffMutateUnlike = useCallback((body) => __awaiter(void 0, void 0, void 0, function* () {
600
+ body = Object.assign(Object.assign({}, body), { productUserId: fakeUserId });
596
601
  const res = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('v1/recommend/unlike', { method: 'POST', body }));
597
602
  return res === null || res === void 0 ? void 0 : res.success;
598
- }), [bffFetch]);
603
+ }), [bffFetch, fakeUserId]);
599
604
  const bffSubmitForm = useCallback((body) => __awaiter(void 0, void 0, void 0, function* () {
600
605
  const res = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('v1/customform', { method: 'POST', body }));
601
606
  return res === null || res === void 0 ? void 0 : res.success;
@@ -15,10 +15,10 @@ const LikeButton = (_a) => {
15
15
  const likeIcon = (0, useIconLink_1.useIconLink)(defaultLikeIconPath);
16
16
  const unlikeIcon = (0, useIconLink_1.useIconLink)(defaultUnLikeIconPath);
17
17
  const handleClick = (0, lodash_1.debounce)(() => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
18
- var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5;
18
+ var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7;
19
19
  if (state) {
20
20
  setState(false);
21
- const result = (_e = (yield (mutateUnlike === null || mutateUnlike === void 0 ? void 0 : mutateUnlike({ videoItemId: (_d = (_c = recData === null || recData === void 0 ? void 0 : recData.video) === null || _c === void 0 ? void 0 : _c.itemId) !== null && _d !== void 0 ? _d : '' })))) !== null && _e !== void 0 ? _e : false;
21
+ const result = (_e = (yield (mutateUnlike === null || mutateUnlike === void 0 ? void 0 : mutateUnlike({ itemId: (_d = (_c = recData === null || recData === void 0 ? void 0 : recData.video) === null || _c === void 0 ? void 0 : _c.itemId) !== null && _d !== void 0 ? _d : '' })))) !== null && _e !== void 0 ? _e : false;
22
22
  bffEventReport === null || bffEventReport === void 0 ? void 0 : bffEventReport({
23
23
  eventInfo: {
24
24
  eventSubject: 'favoriteContentCanceled',
@@ -47,30 +47,30 @@ const LikeButton = (_a) => {
47
47
  }
48
48
  else {
49
49
  setState(true);
50
- const result = (_t = (yield (mutateLike === null || mutateLike === void 0 ? void 0 : mutateLike({ content: JSON.stringify(recData) })))) !== null && _t !== void 0 ? _t : false;
50
+ const result = (_v = (yield (mutateLike === null || mutateLike === void 0 ? void 0 : mutateLike({ content: JSON.stringify(recData), itemId: (_u = (_t = recData === null || recData === void 0 ? void 0 : recData.video) === null || _t === void 0 ? void 0 : _t.itemId) !== null && _u !== void 0 ? _u : '' })))) !== null && _v !== void 0 ? _v : false;
51
51
  bffEventReport === null || bffEventReport === void 0 ? void 0 : bffEventReport({
52
52
  eventInfo: {
53
53
  eventSubject: 'favoriteContent',
54
54
  eventDescription: 'This content was favorite by the user',
55
- contentId: (_v = (_u = recData === null || recData === void 0 ? void 0 : recData.video) === null || _u === void 0 ? void 0 : _u.itemId) !== null && _v !== void 0 ? _v : '',
56
- sceneId: (_y = (_x = (_w = recData === null || recData === void 0 ? void 0 : recData.video) === null || _w === void 0 ? void 0 : _w.scene) === null || _x === void 0 ? void 0 : _x.sceneId) !== null && _y !== void 0 ? _y : '',
57
- contentName: (_0 = (_z = recData === null || recData === void 0 ? void 0 : recData.video) === null || _z === void 0 ? void 0 : _z.title) !== null && _0 !== void 0 ? _0 : '',
58
- contentTags: JSON.stringify((_2 = (_1 = recData === null || recData === void 0 ? void 0 : recData.video) === null || _1 === void 0 ? void 0 : _1.tags) !== null && _2 !== void 0 ? _2 : []),
55
+ contentId: (_x = (_w = recData === null || recData === void 0 ? void 0 : recData.video) === null || _w === void 0 ? void 0 : _w.itemId) !== null && _x !== void 0 ? _x : '',
56
+ sceneId: (_0 = (_z = (_y = recData === null || recData === void 0 ? void 0 : recData.video) === null || _y === void 0 ? void 0 : _y.scene) === null || _z === void 0 ? void 0 : _z.sceneId) !== null && _0 !== void 0 ? _0 : '',
57
+ contentName: (_2 = (_1 = recData === null || recData === void 0 ? void 0 : recData.video) === null || _1 === void 0 ? void 0 : _1.title) !== null && _2 !== void 0 ? _2 : '',
58
+ contentTags: JSON.stringify((_4 = (_3 = recData === null || recData === void 0 ? void 0 : recData.video) === null || _3 === void 0 ? void 0 : _3.tags) !== null && _4 !== void 0 ? _4 : []),
59
59
  position: position + '',
60
- contentFormat: ((_3 = recData === null || recData === void 0 ? void 0 : recData.video) === null || _3 === void 0 ? void 0 : _3.url) ? 'video' : 'image',
61
- traceInfo: (_4 = recData === null || recData === void 0 ? void 0 : recData.video) === null || _4 === void 0 ? void 0 : _4.traceInfo
60
+ contentFormat: ((_5 = recData === null || recData === void 0 ? void 0 : recData.video) === null || _5 === void 0 ? void 0 : _5.url) ? 'video' : 'image',
61
+ traceInfo: (_6 = recData === null || recData === void 0 ? void 0 : recData.video) === null || _6 === void 0 ? void 0 : _6.traceInfo
62
62
  }
63
63
  });
64
64
  if (!result) {
65
65
  setState(false);
66
66
  }
67
67
  else {
68
- const nRtcList = (_5 = cacheRtcList === null || cacheRtcList === void 0 ? void 0 : cacheRtcList.map((item, index) => {
68
+ const nRtcList = (_7 = cacheRtcList === null || cacheRtcList === void 0 ? void 0 : cacheRtcList.map((item, index) => {
69
69
  if (index === position) {
70
70
  item.isCollected = true;
71
71
  }
72
72
  return item;
73
- })) !== null && _5 !== void 0 ? _5 : [];
73
+ })) !== null && _7 !== void 0 ? _7 : [];
74
74
  setCacheRtcList === null || setCacheRtcList === void 0 ? void 0 : setCacheRtcList(nRtcList);
75
75
  }
76
76
  }
@@ -21,12 +21,8 @@ export interface ISxpDataSourceContext {
21
21
  value: string;
22
22
  }>;
23
23
  }) => Promise<boolean | undefined>;
24
- mutateUnlike?: (body: {
25
- videoItemId: string;
26
- }) => Promise<boolean>;
27
- mutateLike?: (body: {
28
- content: string;
29
- }) => Promise<boolean>;
24
+ mutateUnlike?: (body: Record<string, any>) => Promise<boolean>;
25
+ mutateLike?: (body: Record<string, any>) => Promise<boolean>;
30
26
  popupDetailData?: RecItemType;
31
27
  setPopupDetailData?: React.Dispatch<React.SetStateAction<any | null>>;
32
28
  loadVideos?: (page: number) => Promise<RecommendVideoResultType | undefined>;
@@ -107,12 +103,8 @@ export interface SxpDataSourceProviderProps {
107
103
  value: string;
108
104
  }>;
109
105
  }) => Promise<boolean | undefined>;
110
- mutateUnlike: (body: {
111
- videoItemId: string;
112
- }) => Promise<boolean>;
113
- mutateLike: (body: {
114
- content: string;
115
- }) => Promise<boolean>;
106
+ mutateUnlike: (body: Record<string, any>) => Promise<boolean>;
107
+ mutateLike: (body: Record<string, any>) => Promise<boolean>;
116
108
  pageData?: PageData;
117
109
  }) => ReactNode;
118
110
  utmVal?: string;
@@ -110,7 +110,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
110
110
  return ((_a = bffDataSource === null || bffDataSource === void 0 ? void 0 : bffDataSource.headers) === null || _a === void 0 ? void 0 : _a['x-app-id']) + (0, localStore_1.storeAndLoadFeUserId)();
111
111
  }, [bffDataSource]);
112
112
  const bffFetch = (0, react_1.useCallback)((path, options, isBota = true) => {
113
- var _a;
113
+ var _a, _b;
114
114
  if (!bffDataSource)
115
115
  return;
116
116
  const url = bffDataSource.url;
@@ -125,9 +125,9 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
125
125
  const value = val.split('=')[1];
126
126
  params[key] = value;
127
127
  });
128
- options.body = Object.assign(Object.assign({}, options.body), { tenant_id: fakeUserId });
128
+ options.body = Object.assign(Object.assign({}, options.body), { productUserId: fakeUserId });
129
129
  return window
130
- .fetch(`${url}/api/${path}`, Object.assign({ headers: Object.assign({ 'Content-Type': 'application/json', 'x-user-id': fakeUserId }, bffDataSource.headers), method: options.method, body: options.type === 'beacon' && isBota
130
+ .fetch(`${url}/api/${path}`, Object.assign({ headers: Object.assign({ 'Content-Type': 'application/json', 'x-user-id': fakeUserId, 'tenant-id': (_b = bffDataSource === null || bffDataSource === void 0 ? void 0 : bffDataSource.headers) === null || _b === void 0 ? void 0 : _b['x-app-id'] }, bffDataSource.headers), method: options.method, body: options.type === 'beacon' && isBota
131
131
  ? JSON.stringify({
132
132
  body: btoa(encodeURIComponent(JSON.stringify(Object.assign(Object.assign(Object.assign({}, options.body), bffDataSource.headers), { 'x-user-id': fakeUserId }))))
133
133
  })
@@ -429,7 +429,9 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
429
429
  return;
430
430
  }
431
431
  if (!userInfo) {
432
- userInfo = {};
432
+ userInfo = {
433
+ productUserId: fakeUserId
434
+ };
433
435
  }
434
436
  const sessionID = (0, sessionStore_1.storeAndLoadFeSessionId)();
435
437
  const params = {};
@@ -462,7 +464,8 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
462
464
  layoutVariantId,
463
465
  globalConfig,
464
466
  playbookType,
465
- bffDataSource
467
+ bffDataSource,
468
+ fakeUserId
466
469
  ]);
467
470
  const getEventParamsByJson = (0, react_1.useCallback)((json, product) => {
468
471
  var _a, _b, _c;
@@ -592,13 +595,15 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
592
595
  }
593
596
  }, [bffFetch, enableReportEvent, enabledMetaConversionApi, globalConfig, bffDataSource, getEventParamsByJson]);
594
597
  const bffMutateLike = (0, react_1.useCallback)((body) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
598
+ body = Object.assign(Object.assign({}, body), { productUserId: fakeUserId });
595
599
  const res = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('v1/recommend/like', { method: 'POST', body }));
596
600
  return res === null || res === void 0 ? void 0 : res.success;
597
- }), [bffFetch]);
601
+ }), [bffFetch, fakeUserId]);
598
602
  const bffMutateUnlike = (0, react_1.useCallback)((body) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
603
+ body = Object.assign(Object.assign({}, body), { productUserId: fakeUserId });
599
604
  const res = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('v1/recommend/unlike', { method: 'POST', body }));
600
605
  return res === null || res === void 0 ? void 0 : res.success;
601
- }), [bffFetch]);
606
+ }), [bffFetch, fakeUserId]);
602
607
  const bffSubmitForm = (0, react_1.useCallback)((body) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
603
608
  const res = yield (bffFetch === null || bffFetch === void 0 ? void 0 : bffFetch('v1/customform', { method: 'POST', body }));
604
609
  return res === null || res === void 0 ? void 0 : res.success;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pb-sxp-ui",
3
- "version": "1.16.17",
3
+ "version": "1.16.19",
4
4
  "description": "React enterprise-class UI components",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",