ftdsy-attr 2.0.0 → 2.1.0

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.
Files changed (56) hide show
  1. package/dist/ftdsy-attr.cjs.js +1 -1
  2. package/dist/ftdsy-attr.d.ts +81 -63
  3. package/dist/ftdsy-attr.esm.js +1 -1
  4. package/dist/types/api/tb/index.d.ts +2 -2
  5. package/dist/types/category/departmentStore/departmentStore_commodity.d.ts +17 -0
  6. package/dist/types/category/departmentStore/departmentStore_holidaysupplies.d.ts +17 -0
  7. package/dist/types/category/departmentStore/departmentStore_tableware.d.ts +17 -0
  8. package/dist/types/category/numeral/numeral_game.d.ts +17 -0
  9. package/dist/types/category/numeral/numeral_smart.d.ts +17 -0
  10. package/dist/types/category/type.d.ts +18 -0
  11. package/dist/types/main.d.ts +28 -7
  12. package/dist/types/models/index.d.ts +4 -11
  13. package/dist/types/platform/albb.d.ts +6 -0
  14. package/dist/types/platform/albb.type.d.ts +27 -0
  15. package/dist/types/platform/dy.d.ts +3 -0
  16. package/dist/types/platform/dy.type.d.ts +48 -0
  17. package/dist/types/platform/jd.d.ts +3 -0
  18. package/dist/types/platform/jd.type.d.ts +30 -0
  19. package/dist/types/platform/ks.d.ts +3 -0
  20. package/dist/types/platform/ks.type.d.ts +41 -0
  21. package/dist/types/platform/pdd.d.ts +6 -0
  22. package/dist/types/platform/pdd.type.d.ts +28 -0
  23. package/dist/types/platform/shopee.d.ts +6 -0
  24. package/dist/types/platform/shopee.type.d.ts +28 -0
  25. package/dist/types/platform/tb.d.ts +7 -0
  26. package/dist/types/platform/tb.type.d.ts +63 -0
  27. package/dist/types/platform/tiktok.d.ts +6 -0
  28. package/dist/types/platform/tiktok.type.d.ts +1 -0
  29. package/dist/types/platform/tm.d.ts +5 -0
  30. package/dist/types/platform/tm.type.d.ts +1 -0
  31. package/dist/types/platform/wxsph.d.ts +6 -0
  32. package/dist/types/platform/wxsph.type.d.ts +9 -0
  33. package/dist/types/platform/xhs.d.ts +6 -0
  34. package/dist/types/platform/xhs.type.d.ts +16 -0
  35. package/dist/types/property/index.d.ts +3 -3
  36. package/dist/types/property/matchProperty.d.ts +3 -3
  37. package/dist/types/property/perpareProperty.d.ts +3 -3
  38. package/dist/types/property/predictionProperty.d.ts +2 -3
  39. package/dist/types/property/type.d.ts +69 -0
  40. package/dist/types/type.d.ts +63 -32
  41. package/dist/types/utils/is/index.d.ts +23 -0
  42. package/dist/types/utils/utils.d.ts +33 -45
  43. package/package.json +1 -1
  44. package/dist/types/platform/index.d.ts +0 -6
  45. package/dist/types/platform/platform/albb.d.ts +0 -6
  46. package/dist/types/platform/platform/dy.d.ts +0 -6
  47. package/dist/types/platform/platform/jd.d.ts +0 -6
  48. package/dist/types/platform/platform/ks.d.ts +0 -6
  49. package/dist/types/platform/platform/pdd.d.ts +0 -9
  50. package/dist/types/platform/platform/shopee.d.ts +0 -6
  51. package/dist/types/platform/platform/tb.d.ts +0 -6
  52. package/dist/types/platform/platform/tiktok.d.ts +0 -6
  53. package/dist/types/platform/platform/tm.d.ts +0 -6
  54. package/dist/types/platform/platform/wxsph.d.ts +0 -6
  55. package/dist/types/platform/platform/xhs.d.ts +0 -6
  56. package/dist/types/platform/type.d.ts +0 -70
@@ -1,93 +1,111 @@
1
- type Platform = 'pdd' | 'tb' | 'jd' | 'dy' | 'shopee' | 'xhs' | 'ks' | 'dsy' | 'albb' | 'shopeebt' | 'tgc' | 'wxsph' | 'tiktok' | 'tm' | 'tiktokUs';
2
- type GoodsAttr = {
3
- id?: string | number;
1
+ type Pt = 'pdd' | 'tb' | 'jd' | 'dy' | 'shopee' | 'xhs' | 'ks' | 'dsy' | 'albb' | 'shopeebt' | 'tgc' | 'wxsph' | 'tiktok' | 'tm' | 'tiktokUs';
2
+ type PropertyType = 'unknown' | 'input' | 'singleSelect' | 'multiSelect' | 'treeSingleSelect' | 'inputComponent' | 'multiComplex' | 'date' | 'image';
3
+ type RuleName = 'requiredRule' | 'maxLengthRule' | 'valueTypeRule' | 'maxItemsRule' | 'format' | 'regexRule';
4
+ type ComponentType = 'input' | 'unit' | 'select';
5
+ type goodsAttr = {
6
+ id?: string;
4
7
  attr_name: string;
5
8
  value: string | string[];
6
- value_id?: string | number | string[];
9
+ value_id?: string | string[];
7
10
  };
8
- type PropertyItem = {
9
- property_id: string | number;
10
- property_name: string;
11
- property_required: boolean;
12
- property_type: number;
13
- property_value?: number | string | PropertySelectOption[] | PropertySelectOption | object;
14
- property_values: PropertySelectOption[];
15
- select_max_num: number;
16
- select_custom: boolean;
17
- input_num: number;
18
- input_max_num: number;
19
- input_type: string;
20
- property_unit: string;
21
- property_units: string[];
22
- input_operator?: string;
23
- input_values?: PropertyInputOption[];
24
- date_format: string;
25
- has_children: boolean;
26
- show?: boolean;
27
- show_condition: PropertyShowCondition[];
28
- condition_values: PropertySelectOption[];
29
- property_tips?: string;
30
- measure_templates?: any;
31
- property_cstore?: boolean;
32
- };
33
- type PropertySelectOption = {
34
- name: string;
35
- value_id: string;
11
+ type propertyOption = {
12
+ label: string;
36
13
  value: string;
37
14
  parent_value?: string[];
38
- parent_id?: string;
39
- parent_name?: string;
40
- children_values?: PropertySelectOption[];
41
- disableContent?: boolean;
42
- content?: number;
43
- similarity?: number;
15
+ value_path?: string;
16
+ value_ids_path?: string[];
17
+ children?: propertyOption[];
18
+ };
19
+ type PropertyComponent = {
20
+ type: string;
21
+ name?: string;
22
+ placeholder?: string;
23
+ options: propertyOption[];
24
+ text?: string;
25
+ precision?: number;
44
26
  };
45
- type PropertyInputOption = {
46
- title: string;
27
+ type Rule = {
28
+ name: RuleName;
47
29
  value: string;
30
+ exProperty?: string;
48
31
  };
49
- type PropertyShowCondition = {
50
- parent_property_id: string;
51
- parent_property_value: string[];
32
+ type DsyAttr = {
33
+ property_id: string;
34
+ property_required: boolean;
35
+ property_name: string;
36
+ property_type: PropertyType;
37
+ property_values: propertyOption[];
38
+ property_component?: PropertyComponent[];
39
+ property_tips?: string;
40
+ rules: Rule[];
41
+ has_children: boolean;
42
+ select_custom?: boolean;
43
+ show_condition?: Condition[];
44
+ measure_templates?: any;
45
+ isCStore?: boolean;
52
46
  };
53
-
54
- /**
55
- * 生成自定义属性列表
56
- * 对目标平台的属性列表进行处理,获取转换后的自定义属性列表
57
- * */
58
- declare function createCategoryProperties(platform: Platform, pt_attrs: any[]): PropertyItem[];
59
-
60
- interface MatchGoods {
47
+ type Condition = {
48
+ parent_id: string;
49
+ parent_value_ids: string[];
50
+ };
51
+ type DsyAttrValue = {
52
+ valueId: string | string[];
53
+ value: string | string[];
54
+ };
55
+ type DsyAttrWithValue = DsyAttr & DsyAttrValue;
56
+ type MatchDatas = {
57
+ cate_id: string | number;
58
+ cate_path: string | string[];
59
+ platform: string;
60
+ properties: any[];
61
+ attrs?: any[];
61
62
  title?: string;
62
63
  goods_sn?: string;
63
64
  ccc_code?: string;
64
65
  remark?: string;
65
- }
66
- interface MatchDatas extends MatchGoods {
67
- cate_id: string;
68
- cate_path: string;
69
- platform: Platform;
70
- properties: any[];
71
- attrs?: any[];
72
- }
66
+ specs?: any;
67
+ };
73
68
 
74
69
  declare const _default: {
75
70
  version: string;
76
- matchCategoryProperties: typeof matchCategoryProperties;
77
71
  createCategoryProperties: typeof createCategoryProperties;
72
+ matchCategoryProperties: typeof matchCategoryProperties;
78
73
  createCategoryPropertyTemplate: typeof createCategoryPropertyTemplate;
79
74
  };
80
75
 
76
+ /**
77
+ * 转换自定义属性列表,
78
+ * */
79
+ declare function createCategoryProperties(platform: Pt, ptAttrs: any): DsyAttr[] | null;
81
80
  /**
82
81
  * 匹配属性值
83
82
  * @param matchDatas 匹配数据
84
83
  * @param matchLevel 匹配等级
85
- * @param outType 匹配结果输出类型 group: 分组,template: 模板
84
+ * @param outType 匹配结果输出类型 group: 分组(已去除),template: 模板, list: 自定义属性列表(不含’品牌‘)
86
85
  * */
87
- declare function matchCategoryProperties(matchDatas: MatchDatas, matchLevel?: number, outType?: string): Promise<unknown>;
86
+ declare function matchCategoryProperties(matchDatas: MatchDatas, matchLevel?: number, outType?: 'template' | 'list'): Promise<{
87
+ msg: string;
88
+ data: DsyAttrWithValue[];
89
+ code: number;
90
+ } | {
91
+ msg: string;
92
+ data: goodsAttr[];
93
+ code: number;
94
+ }>;
88
95
  /**
89
96
  * 创建分类属性模板
97
+ *
98
+ * 返回案例如下:
99
+ * input: { attr_name: '货号', value: 'abc' };
100
+ * date: { attr_name: '日期', value: '2025-8-1' };
101
+ * inputComponent: { attr_name: '含量', value: '100%' };
102
+ * singleSelect: { attr_name: '材质', value: '聚酯纤维' };
103
+ * singleSelect: { attr_name: '材质', value: '聚酯纤维' };
104
+ * multiSelect: { attr_name: '材质', value: '[聚酯纤维, 棉]' };
105
+ * multiComplex: { attr_name: '材质', value: '[聚酯纤维[80%], 棉[20%]]' };
106
+ * treeSingleSelect: { attr_name: '风格', value: '休闲风-简约风' };
90
107
  * */
91
- declare function createCategoryPropertyTemplate(properties: any[]): GoodsAttr[];
108
+ declare function createCategoryPropertyTemplate(properties: (DsyAttrWithValue | goodsAttr)[]): goodsAttr[];
92
109
 
93
110
  export { _default as default };
111
+ export type { ComponentType, Condition, DsyAttr, DsyAttrValue, DsyAttrWithValue, MatchDatas, PropertyComponent, PropertyType, Pt, Rule, RuleName, goodsAttr, propertyOption };