@polyv/product-sdk 1.2.0-rc-20250724.2 → 1.4.0-rc-20250904.1

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/index.es.d.ts CHANGED
@@ -1,15 +1,15 @@
1
- import { CommonResult } from '@polyv/iar-core-sdk';
1
+ import { CommonResult } from '@polyv/interaction-core';
2
2
  import { EventEmitter } from '@polyv/utils/es/event';
3
- import { InteractionReceiveCore } from '@polyv/iar-core-sdk';
3
+ import { InteractionCore } from '@polyv/interaction-core';
4
4
  import { LinkJumpWay } from '@polyv/utils/es/external-link';
5
5
  import { LinkType } from '@polyv/utils/es/external-link';
6
- import { PageContent } from '@polyv/iar-core-sdk';
7
- import { PageOptions } from '@polyv/iar-core-sdk';
6
+ import { PageContent } from '@polyv/interaction-core';
7
+ import { PageOptions } from '@polyv/interaction-core';
8
8
 
9
9
  export declare class Address {
10
- iarCore: InteractionReceiveCore;
10
+ interactionCore: InteractionCore;
11
11
  config: ProductSDKConfig;
12
- constructor(iarCore: InteractionReceiveCore, config: ProductSDKConfig);
12
+ constructor(interactionCore: InteractionCore, config: ProductSDKConfig);
13
13
  /**
14
14
  * 获取地址列表
15
15
  * @param params 分页参数
@@ -273,6 +273,14 @@ export declare interface FinanceProductData extends ProductBasicData, ProductLin
273
273
  yield: string;
274
274
  }
275
275
 
276
+ export declare interface GetLaunchProductListParams {
277
+ pageNumber?: number;
278
+ pageSize?: number;
279
+ keyword?: string;
280
+ /** 在架状态 */
281
+ status?: ProductStatus;
282
+ }
283
+
276
284
  /**
277
285
  * 获取订单详情参数
278
286
  */
@@ -326,6 +334,17 @@ export declare interface GetProductListParams {
326
334
  page?: number;
327
335
  }
328
336
 
337
+ export declare interface LaunchProductListResult extends PageContent<ProductData> {
338
+ /**
339
+ * 上架数量
340
+ */
341
+ upCount: number;
342
+ /**
343
+ * 下架数量
344
+ */
345
+ downCount: number;
346
+ }
347
+
329
348
  export declare type MaybePromise<R> = () => Promise<R> | R;
330
349
 
331
350
  /**
@@ -395,7 +414,7 @@ export declare interface NormalProductData extends ProductBasicData, ProductLink
395
414
  }
396
415
 
397
416
  export declare class Order {
398
- iarCore: InteractionReceiveCore;
417
+ interactionCore: InteractionCore;
399
418
  config: ProductSDKConfig;
400
419
  OrderStatus: typeof OrderStatus;
401
420
  PayStatus: typeof PayStatus;
@@ -406,7 +425,7 @@ export declare class Order {
406
425
  RefundStatus: typeof RefundStatus;
407
426
  CreateOrderFailReason: typeof CreateOrderFailReason;
408
427
  OrderRefundFailReason: typeof OrderRefundFailReason;
409
- constructor(iarCore: InteractionReceiveCore, config: ProductSDKConfig);
428
+ constructor(interactionCore: InteractionCore, config: ProductSDKConfig);
410
429
  /**
411
430
  * 获取订单列表
412
431
  * @param params 获取参数
@@ -701,10 +720,10 @@ export declare interface OrderWaitPayData extends OrderBasicData {
701
720
  }
702
721
 
703
722
  export declare class Payment {
704
- iarCore: InteractionReceiveCore;
723
+ interactionCore: InteractionCore;
705
724
  config: ProductSDKConfig;
706
725
  PaymentProvider: typeof PaymentProvider;
707
- constructor(iarCore: InteractionReceiveCore, config: ProductSDKConfig);
726
+ constructor(interactionCore: InteractionCore, config: ProductSDKConfig);
708
727
  /**
709
728
  * 获取微信/支付宝支付参数
710
729
  * @param options 支付订单参数
@@ -788,12 +807,9 @@ export declare interface PositionProductData extends ProductBasicData, ProductLi
788
807
  treatment: string;
789
808
  }
790
809
 
791
- /**
792
- * 商品库 SDK 模块
793
- */
794
810
  export declare class Product {
795
- iarCore: InteractionReceiveCore;
796
- config: ProductSDKConfig;
811
+ interactionCore: InteractionCore;
812
+ config?: ProductSDKConfig | undefined;
797
813
  ProductType: typeof ProductType;
798
814
  ProductLinkType: typeof ProductLinkType;
799
815
  ProductLinkJumpWay: typeof ProductLinkJumpWay;
@@ -810,7 +826,7 @@ export declare class Product {
810
826
  private __currentPushingProductId;
811
827
  private __currentPushingProductPushRule;
812
828
  private __isPushingProduct;
813
- constructor(iarCore: InteractionReceiveCore, config: ProductSDKConfig);
829
+ constructor(interactionCore: InteractionCore, config?: ProductSDKConfig | undefined);
814
830
  /* Excluded from this release type: __clearCurrentPushingProduct */
815
831
  /**
816
832
  * 获取商品标签列表
@@ -837,6 +853,11 @@ export declare class Product {
837
853
  * ```
838
854
  */
839
855
  getProductList(params?: GetProductListParams): Promise<ProductListResult>;
856
+ /**
857
+ * 获取商品列表(发起端)
858
+ * @param params 获取参数
859
+ */
860
+ getLaunchProductList(params: GetLaunchProductListParams): Promise<LaunchProductListResult>;
840
861
  /**
841
862
  * 获取商品数据
842
863
  * @param productId 商品 id
@@ -918,6 +939,7 @@ export declare class Product {
918
939
  /* Excluded from this release type: getCurrentPushingProductId */
919
940
  /**
920
941
  * 获取当前推送中的商品数据
942
+ * @param productId 可选,指定商品ID,如果不提供则获取当前配置中的推送商品
921
943
  * @example
922
944
  * ```js
923
945
  * const productData = await productTarget.getCurrentPushingProduct();
@@ -925,6 +947,120 @@ export declare class Product {
925
947
  * ```
926
948
  */
927
949
  getCurrentPushingProduct(productId?: number): Promise<ProductData | undefined>;
950
+ protected _explainProduct(productId: number, recordType: ProductExplainOperation): Promise<void | undefined>;
951
+ /**
952
+ * 开始商品讲解
953
+ * @param productId 商品 id
954
+ * @example
955
+ * ```js
956
+ * await productTarget.startExplain(123);
957
+ * ```
958
+ */
959
+ startExplain(productId: number): Promise<void> | undefined;
960
+ /**
961
+ * 重新开始商品讲解
962
+ * @param productId 商品 id
963
+ * @example
964
+ * ```js
965
+ * await productTarget.restartExplain(123);
966
+ * ```
967
+ */
968
+ restartExplain(productId: number): Promise<void> | undefined;
969
+ /**
970
+ * 结束商品讲解
971
+ * @param productId 商品 id
972
+ * @example
973
+ * ```js
974
+ * await productTarget.endExplain(123);
975
+ * ```
976
+ */
977
+ endExplain(productId: number): Promise<void> | undefined;
978
+ /**
979
+ * 删除商品讲解
980
+ * @param productId 商品 id
981
+ * @example
982
+ * ```js
983
+ * await productTarget.deleteExplain(123);
984
+ * ```
985
+ */
986
+ deleteExplain(productId: number): Promise<void>;
987
+ /**
988
+ * 获取当前正在讲解的商品 id
989
+ * @example
990
+ * ```js
991
+ * const productId = await productTarget.getCurrentProductExplain();
992
+ * console.log('当前正在讲解的商品 id', productId);
993
+ * ```
994
+ */
995
+ getCurrentProductExplain(): Promise<number | null>;
996
+ /**
997
+ * 商品开价
998
+ * @param productId 商品 id
999
+ * @example
1000
+ * ```js
1001
+ * await productTarget.openProductPrice(123);
1002
+ * ```
1003
+ */
1004
+ openProductPrice(productId: number): Promise<void>;
1005
+ /**
1006
+ * 商品隐藏价格
1007
+ * @param productId 商品 id
1008
+ * @example
1009
+ * ```js
1010
+ * await productTarget.hideProductPrice(123);
1011
+ * ```
1012
+ */
1013
+ hideProductPrice(productId: number): Promise<void>;
1014
+ /**
1015
+ * 获取商品设置
1016
+ */
1017
+ getProductSetting(): Promise<ProductSetting>;
1018
+ /**
1019
+ * 推送商品
1020
+ * @param productId 商品 id
1021
+ * @param rule 推送规则
1022
+ * @example
1023
+ * ```js
1024
+ * await productTarget.pushProduct(123, ProductPushRule.SmallCard);
1025
+ * ```
1026
+ */
1027
+ pushProduct(productId: number, rule?: ProductPushRule): Promise<void>;
1028
+ /**
1029
+ * 取消推送商品
1030
+ * @param productId 商品 id
1031
+ * @example
1032
+ * ```js
1033
+ * await productTarget.cancelPushProduct(123);
1034
+ * ```
1035
+ */
1036
+ cancelPushProduct(productId: number): Promise<void>;
1037
+ /**
1038
+ * 批量删除商品
1039
+ * @param productIds 商品 id 列表
1040
+ * @example
1041
+ * ```js
1042
+ * await productTarget.batchDeleteProduct([123, 456]);
1043
+ * ```
1044
+ */
1045
+ batchDeleteProduct(productIds: number[]): Promise<void>;
1046
+ /**
1047
+ * 批量上架商品
1048
+ * @param productIds 商品 id 列表
1049
+ * @example
1050
+ * ```js
1051
+ * await productTarget.batchOnShelfProduct([123, 456]);
1052
+ * ```
1053
+ */
1054
+ batchOnShelfProduct(productIds: number[]): Promise<void>;
1055
+ /**
1056
+ * 批量下架商品
1057
+ * @param productIds 商品 id 列表
1058
+ * @example
1059
+ * ```js
1060
+ * await productTarget.batchOffShelfProduct([123, 456]);
1061
+ * ```
1062
+ */
1063
+ batchOffShelfProduct(productIds: number[]): Promise<void>;
928
1064
  /**
929
1065
  * 判断当前用户是否支持直接购买商品
930
1066
  * @example
@@ -1004,6 +1140,10 @@ export declare interface ProductBasicData {
1004
1140
  * 商品推送记录 id
1005
1141
  */
1006
1142
  pushLogId?: string;
1143
+ /**
1144
+ * 排序
1145
+ */
1146
+ rank: number;
1007
1147
  /**
1008
1148
  * 原始数据
1009
1149
  */
@@ -1053,7 +1193,7 @@ export declare interface ProductConfig {
1053
1193
  /**
1054
1194
  * 埋点上报总开关
1055
1195
  */
1056
- watchEventTrackEnabled: boolean;
1196
+ watchEventTrackEnabled?: boolean;
1057
1197
  /**
1058
1198
  * 互动事件上报开关
1059
1199
  */
@@ -1065,7 +1205,7 @@ export declare interface ProductConfig {
1065
1205
  /**
1066
1206
  * 商品讲解开关
1067
1207
  */
1068
- productExplainEnabled: boolean;
1208
+ productExplainEnabled?: boolean;
1069
1209
  /**
1070
1210
  * 商品热卖中开关
1071
1211
  */
@@ -1077,15 +1217,19 @@ export declare interface ProductConfig {
1077
1217
  /**
1078
1218
  * 点击商品的封面/标题区域是否直接跳转外链
1079
1219
  */
1080
- outLinkProductRedirectEnabled: boolean;
1220
+ outLinkProductRedirectEnabled?: boolean;
1081
1221
  /**
1082
1222
  * 商品订单入口是否显示
1083
1223
  */
1084
- productPayOrderEnabled: boolean;
1224
+ productPayOrderEnabled?: boolean;
1085
1225
  /**
1086
1226
  * 商品库链接跳转提示
1087
1227
  */
1088
1228
  productLinkJumpTipEnabled?: boolean;
1229
+ /**
1230
+ * 业务逻辑上是否允许直接购买
1231
+ */
1232
+ directBuyEnabled?: boolean;
1089
1233
  }
1090
1234
 
1091
1235
  /**
@@ -1107,61 +1251,163 @@ export declare enum ProductDeliveryType {
1107
1251
  Virtual = "virtual"
1108
1252
  }
1109
1253
 
1254
+ /**
1255
+ * 商品事件
1256
+ * @eventenum {@link ProductEventsRelations}
1257
+ */
1110
1258
  export declare enum ProductEvents {
1111
1259
  /**
1112
1260
  * 上架商品
1261
+ * @description 当商品上架时,会触发该事件
1262
+ * @example
1263
+ * ```js
1264
+ * productTarget.eventEmitter.on(ProductEvents.OnSaleProduct, (data) => {
1265
+ * console.log('商品数据', data.productData);
1266
+ * });
1267
+ * ```
1113
1268
  */
1114
1269
  OnSaleProduct = "OnSaleProduct",
1115
1270
  /**
1116
1271
  * 下架商品
1272
+ * @description 当商品下架时,会触发该事件
1273
+ * @example
1274
+ * ```js
1275
+ * productTarget.eventEmitter.on(ProductEvents.OffSaleProduct, (data) => {
1276
+ * console.log('商品数据', data.productData);
1277
+ * });
1278
+ * ```
1117
1279
  */
1118
1280
  OffSaleProduct = "OffSaleProduct",
1119
1281
  /**
1120
1282
  * 添加商品
1283
+ * @description 当商品添加时,会触发该事件
1284
+ * @example
1285
+ * ```js
1286
+ * productTarget.eventEmitter.on(ProductEvents.AddProduct, (data) => {
1287
+ * console.log('商品数据', data.productData);
1288
+ * });
1289
+ * ```
1121
1290
  */
1122
1291
  AddProduct = "AddProduct",
1123
1292
  /**
1124
1293
  * 删除商品
1294
+ * @description 当商品删除时,会触发该事件
1295
+ * @example
1296
+ * ```js
1297
+ * productTarget.eventEmitter.on(ProductEvents.DeleteProduct, (data) => {
1298
+ * console.log('商品 id', data.productId);
1299
+ * });
1300
+ * ```
1125
1301
  */
1126
1302
  DeleteProduct = "DeleteProduct",
1127
1303
  /**
1128
1304
  * 修改商品
1305
+ * @description 当商品修改时,会触发该事件
1306
+ * @example
1307
+ * ```js
1308
+ * productTarget.eventEmitter.on(ProductEvents.ChangeProduct, (data) => {
1309
+ * console.log('商品数据', data.productData);
1310
+ * });
1311
+ * ```
1129
1312
  */
1130
1313
  ChangeProduct = "ChangeProduct",
1131
1314
  /**
1132
1315
  * 上移或下移商品
1316
+ * @description 当商品上移或下移时,会触发该事件
1317
+ * @example
1318
+ * ```js
1319
+ * productTarget.eventEmitter.on(ProductEvents.MoveProduct, (data) => {
1320
+ * console.log('发生改变的两个商品', data.targetProducts);
1321
+ * });
1322
+ * ```
1133
1323
  */
1134
1324
  MoveProduct = "MoveProduct",
1135
1325
  /**
1136
1326
  * 修改商品排序
1327
+ * @description 当商品排序修改时,会触发该事件
1328
+ * @example
1329
+ * ```js
1330
+ * productTarget.eventEmitter.on(ProductEvents.ChangeProductRank, (data) => {
1331
+ * console.log('商品数据', data.productData);
1332
+ * });
1333
+ * ```
1137
1334
  */
1138
1335
  ChangeProductRank = "ChangeProductRank",
1139
1336
  /**
1140
1337
  * 商品售罄
1338
+ * @description 当商品售罄时,会触发该事件
1339
+ * @example
1340
+ * ```js
1341
+ * productTarget.eventEmitter.on(ProductEvents.ProductSoldOut, (data) => {
1342
+ * console.log('商品 id', data.productId);
1343
+ * });
1344
+ * ```
1141
1345
  */
1142
1346
  ProductSoldOut = "ProductSoldOut",
1143
1347
  /**
1144
1348
  * 推送商品
1349
+ * @description 当商品推送时,会触发该事件
1350
+ * @example
1351
+ * ```js
1352
+ * productTarget.eventEmitter.on(ProductEvents.PushProduct, (data) => {
1353
+ * console.log('商品数据', data.productData);
1354
+ * });
1355
+ * ```
1145
1356
  */
1146
1357
  PushProduct = "PushProduct",
1147
1358
  /**
1148
1359
  * 取消推送商品
1360
+ * @description 当商品取消推送时,会触发该事件
1361
+ * @example
1362
+ * ```js
1363
+ * productTarget.eventEmitter.on(ProductEvents.CancelPushProduct, (data) => {
1364
+ * console.log('商品 id', data.productId);
1365
+ * });
1366
+ * ```
1149
1367
  */
1150
1368
  CancelPushProduct = "CancelPushProduct",
1151
1369
  /**
1152
1370
  * 商品库列表开关
1371
+ * @description 当商品库列表开关时,会触发该事件
1372
+ * @example
1373
+ * ```js
1374
+ * productTarget.eventEmitter.on(ProductEvents.ProductListEnabled, (data) => {
1375
+ * console.log('开启或关闭', data.enabled);
1376
+ * });
1377
+ * ```
1153
1378
  */
1154
1379
  ProductListEnabled = "ProductListEnabled",
1155
1380
  /**
1156
1381
  * 刷新当前商品列表
1382
+ * @description 当商品列表刷新时,会触发该事件
1383
+ * @example
1384
+ * ```js
1385
+ * productTarget.eventEmitter.on(ProductEvents.RefreshProductList, (data) => {
1386
+ * console.log('商品列表', data.productList);
1387
+ * });
1388
+ * ```
1157
1389
  */
1158
1390
  RefreshProductList = "RefreshProductList",
1159
1391
  /**
1160
1392
  * 商品点击事件
1393
+ * @description 当商品点击时,会触发该事件
1394
+ * @example
1395
+ * ```js
1396
+ * productTarget.eventEmitter.on(ProductEvents.ProductClick, (data) => {
1397
+ * console.log('商品 id', data.productId);
1398
+ * });
1399
+ * ```
1161
1400
  */
1162
1401
  ProductClick = "ProductClick",
1163
1402
  /**
1164
1403
  * 商品点击次数统计事件
1404
+ * @description 当点击次数发生改变时,会触发该事件
1405
+ * @example
1406
+ * ```js
1407
+ * productTarget.eventEmitter.on(ProductEvents.ProductClickTimes, (data) => {
1408
+ * console.log('商品 id', data.productId);
1409
+ * });
1410
+ * ```
1165
1411
  */
1166
1412
  ProductClickTimes = "ProductClickTimes"
1167
1413
  }
@@ -1285,6 +1531,24 @@ export declare interface ProductExplainData {
1285
1531
  explainType?: ProductExplainType;
1286
1532
  }
1287
1533
 
1534
+ /**
1535
+ * 商品讲解操作
1536
+ */
1537
+ export declare const enum ProductExplainOperation {
1538
+ /**
1539
+ * 开始讲解
1540
+ */
1541
+ Start = "start",
1542
+ /**
1543
+ * 结束讲解
1544
+ */
1545
+ End = "end",
1546
+ /**
1547
+ * 重新讲解
1548
+ */
1549
+ Restart = "restart"
1550
+ }
1551
+
1288
1552
  /**
1289
1553
  * 商品讲解状态
1290
1554
  */
@@ -1514,7 +1778,7 @@ export declare interface ProductSDKConfig {
1514
1778
  /**
1515
1779
  * 传入的商品配置
1516
1780
  */
1517
- getProductConfig: MaybePromise<ProductConfig>;
1781
+ getProductConfig?: MaybePromise<ProductConfig>;
1518
1782
  }
1519
1783
 
1520
1784
  /**
@@ -1531,6 +1795,23 @@ export declare enum ProductServiceType {
1531
1795
  Custom = "custom"
1532
1796
  }
1533
1797
 
1798
+ /**
1799
+ * 商品设置
1800
+ */
1801
+ export declare interface ProductSetting {
1802
+ /** 商品讲解开关 */
1803
+ productExplainEnabled: boolean;
1804
+ /** 商品讲解自动推送置顶 */
1805
+ productExplainingAutoPushAndSticky: boolean;
1806
+ /** 商品推送方式 */
1807
+ productPushRule: ProductPushRule | 'chooseCard';
1808
+ /** 推送中的商品 */
1809
+ pushingProduct?: {
1810
+ productId: number;
1811
+ pushRule: ProductPushRule;
1812
+ };
1813
+ }
1814
+
1534
1815
  /**
1535
1816
  * 商品状态
1536
1817
  */
@@ -1542,7 +1823,7 @@ export declare enum ProductStatus {
1542
1823
  /**
1543
1824
  * 下架
1544
1825
  */
1545
- OffSale = 0
1826
+ OffSale = 2
1546
1827
  }
1547
1828
 
1548
1829
  /**