ftdsy-attr 2.1.6 → 2.1.8

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.
@@ -0,0 +1,116 @@
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' | 'operator' | 'label';
5
+ type goodsAttr = {
6
+ id?: string;
7
+ attr_name: string;
8
+ value: string | string[];
9
+ value_id?: string | string[];
10
+ };
11
+ type PropertyOption = {
12
+ label: string;
13
+ value: string;
14
+ parent_value?: string[];
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;
26
+ };
27
+ type Rule = {
28
+ name: RuleName;
29
+ value: string;
30
+ exProperty?: string;
31
+ };
32
+ type Condition = {
33
+ parent_id: string;
34
+ parent_value_ids: string[];
35
+ };
36
+ type DsyAttr = {
37
+ property_id: string;
38
+ property_required: boolean;
39
+ property_name: string;
40
+ property_type: PropertyType;
41
+ property_values: PropertyOption[];
42
+ property_component?: PropertyComponent[];
43
+ property_tips?: string;
44
+ rules: Rule[];
45
+ has_children: boolean;
46
+ select_custom?: boolean;
47
+ show_condition?: Condition[];
48
+ measure_templates?: any;
49
+ isCStore?: boolean;
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[];
62
+ title?: string;
63
+ goods_sn?: string;
64
+ ccc_code?: string;
65
+ remark?: string;
66
+ specs?: any;
67
+ };
68
+
69
+ declare const getGlobal: () => any;
70
+ declare const _default: {
71
+ createCategoryProperties: typeof createCategoryProperties;
72
+ getOriginProperty: typeof getOriginProperty;
73
+ matchCategoryProperties: typeof matchCategoryProperties;
74
+ createCategoryPropertyTemplate: typeof createCategoryPropertyTemplate;
75
+ };
76
+
77
+ /**
78
+ * 转换自定义属性列表,
79
+ * */
80
+ declare function createCategoryProperties(platform: Pt, ptAttrs: any): DsyAttr[] | null;
81
+ /**
82
+ * 自定义属性类型装换回原来的类型
83
+ * */
84
+ declare function getOriginProperty(platform: Pt, type: string): string;
85
+ /**
86
+ * 匹配属性值
87
+ * @param matchDatas 匹配数据
88
+ * @param matchLevel 匹配等级
89
+ * @param outType 匹配结果输出类型 group: 分组(已去除),template: 模板, list: 自定义属性列表(不含’品牌‘)
90
+ * */
91
+ declare function matchCategoryProperties(matchDatas: MatchDatas, matchLevel?: number, outType?: 'template' | 'list'): Promise<{
92
+ msg: string;
93
+ data: DsyAttrWithValue[];
94
+ code: number;
95
+ } | {
96
+ msg: string;
97
+ data: goodsAttr[];
98
+ code: number;
99
+ }>;
100
+ /**
101
+ * 创建分类属性模板
102
+ *
103
+ * 返回案例如下:
104
+ * input: { attr_name: '货号', value: 'abc' };
105
+ * date: { attr_name: '日期', value: '2025-8-1' };
106
+ * inputComponent: { attr_name: '含量', value: '100%' };
107
+ * singleSelect: { attr_name: '材质', value: '聚酯纤维' };
108
+ * singleSelect: { attr_name: '材质', value: '聚酯纤维' };
109
+ * multiSelect: { attr_name: '材质', value: '[聚酯纤维, 棉]' };
110
+ * multiComplex: { attr_name: '材质', value: '[聚酯纤维[80%], 棉[20%]]' };
111
+ * treeSingleSelect: { attr_name: '风格', value: '休闲风-简约风' };
112
+ * */
113
+ declare function createCategoryPropertyTemplate(properties: (DsyAttrWithValue | goodsAttr)[]): goodsAttr[];
114
+
115
+ export { _default as default, getGlobal };
116
+ export type { ComponentType, Condition, DsyAttr, DsyAttrValue, DsyAttrWithValue, MatchDatas, PropertyComponent, PropertyOption, PropertyType, Pt, Rule, RuleName, goodsAttr };
@@ -74973,18 +74973,36 @@ var error = {
74973
74973
  }
74974
74974
  };
74975
74975
 
74976
- // 全局对象 polyfill
74977
- if (typeof globalThis === 'undefined') {
74978
- window.globalThis = globalThis;
74979
- }
74980
- if (typeof globalThis === 'undefined') {
74981
- globalThis.global = globalThis;
74982
- }
74976
+ // 增强全局对象 polyfill
74977
+ (function () {
74978
+ if (typeof globalThisThis !== 'undefined') return globalThisThis;
74979
+ return globalThis;
74980
+ })();
74983
74981
 
74984
- // 确保 globalThis 在非浏览器环境有定义
74985
- if (typeof globalThis === 'undefined') {
74986
- globalThis.self = globalThis;
74987
- }
74982
+ // 确保所有全局对象引用都指向 globalThisThis
74983
+ Object.defineProperty(globalThisObject, 'globalThis', {
74984
+ value: globalThisObject,
74985
+ writable: true,
74986
+ enumerable: false,
74987
+ configurable: true
74988
+ });
74989
+ Object.defineProperty(globalThisObject, 'globalThis', {
74990
+ value: globalThisObject,
74991
+ writable: true,
74992
+ enumerable: false,
74993
+ configurable: true
74994
+ });
74995
+ Object.defineProperty(globalThisObject, 'globalThis', {
74996
+ value: globalThisObject,
74997
+ writable: true,
74998
+ enumerable: false,
74999
+ configurable: true
75000
+ });
75001
+
75002
+ // 导出全局对象
75003
+ var getGlobal = function getGlobal() {
75004
+ return globalThisObject;
75005
+ };
74988
75006
  var main = {
74989
75007
  createCategoryProperties: createCategoryProperties,
74990
75008
  getOriginProperty: getOriginProperty,
@@ -75241,5 +75259,5 @@ function createCategoryPropertyTemplate(properties) {
75241
75259
  return attrs;
75242
75260
  }
75243
75261
 
75244
- export { main as default };
75262
+ export { main as default, getGlobal };
75245
75263
  //# sourceMappingURL=ftdsy-attr.esm.mjs.map