@pisell/pisellos 2.1.60 → 2.1.61
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/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/modules/Cart/types.d.ts +0 -2
- package/dist/modules/Cart/utils/cartProduct.js +0 -11
- package/dist/modules/Customer/index.js +1 -1
- package/dist/modules/Discount/types.d.ts +0 -15
- package/dist/modules/Payment/index.d.ts +1 -2
- package/dist/modules/Payment/index.js +7 -10
- package/dist/modules/Payment/utils.js +0 -3
- package/dist/modules/Payment/walletpass.d.ts +0 -23
- package/dist/modules/Payment/walletpass.js +95 -191
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/Rules/index.d.ts +3 -8
- package/dist/modules/Rules/index.js +28 -158
- package/dist/modules/Rules/types.d.ts +0 -1
- package/dist/modules/Summary/types.d.ts +0 -2
- package/dist/modules/Summary/utils.d.ts +0 -6
- package/dist/modules/Summary/utils.js +0 -21
- package/dist/plugins/window.d.ts +0 -2
- package/dist/solution/BookingByStep/index.d.ts +0 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/Checkout/index.js +0 -2
- package/dist/solution/ShopDiscount/index.d.ts +0 -1
- package/dist/solution/ShopDiscount/index.js +1 -11
- package/dist/solution/ShopDiscount/types.d.ts +0 -1
- package/dist/solution/ShopDiscount/utils.js +11 -26
- package/lib/index.d.ts +0 -1
- package/lib/index.js +1 -3
- package/lib/modules/Cart/types.d.ts +0 -2
- package/lib/modules/Cart/utils/cartProduct.js +0 -9
- package/lib/modules/Customer/index.js +1 -1
- package/lib/modules/Discount/types.d.ts +0 -15
- package/lib/modules/Payment/index.d.ts +1 -2
- package/lib/modules/Payment/index.js +0 -1
- package/lib/modules/Payment/utils.js +0 -3
- package/lib/modules/Payment/walletpass.d.ts +0 -23
- package/lib/modules/Payment/walletpass.js +17 -94
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/Rules/index.d.ts +3 -8
- package/lib/modules/Rules/index.js +191 -373
- package/lib/modules/Rules/types.d.ts +0 -1
- package/lib/modules/Summary/types.d.ts +0 -2
- package/lib/modules/Summary/utils.d.ts +0 -6
- package/lib/modules/Summary/utils.js +0 -15
- package/lib/plugins/window.d.ts +0 -2
- package/lib/solution/BookingByStep/index.d.ts +0 -1
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.js +6 -0
- package/lib/solution/Checkout/index.js +0 -2
- package/lib/solution/ShopDiscount/index.d.ts +0 -1
- package/lib/solution/ShopDiscount/index.js +0 -6
- package/lib/solution/ShopDiscount/types.d.ts +0 -1
- package/lib/solution/ShopDiscount/utils.js +6 -10
- package/package.json +1 -1
- package/dist/model/index.d.ts +0 -1
- package/dist/model/index.js +0 -1
- package/dist/model/strategy/adapter/index.d.ts +0 -3
- package/dist/model/strategy/adapter/index.js +0 -4
- package/dist/model/strategy/adapter/type.d.ts +0 -28
- package/dist/model/strategy/adapter/type.js +0 -1
- package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +0 -84
- package/dist/model/strategy/adapter/walletPass/evaluator.js +0 -496
- package/dist/model/strategy/adapter/walletPass/example.d.ts +0 -4
- package/dist/model/strategy/adapter/walletPass/example.js +0 -258
- package/dist/model/strategy/adapter/walletPass/index.d.ts +0 -32
- package/dist/model/strategy/adapter/walletPass/index.js +0 -182
- package/dist/model/strategy/adapter/walletPass/locales.d.ts +0 -1
- package/dist/model/strategy/adapter/walletPass/locales.js +0 -23
- package/dist/model/strategy/adapter/walletPass/type.d.ts +0 -163
- package/dist/model/strategy/adapter/walletPass/type.js +0 -1
- package/dist/model/strategy/adapter/walletPass/utils.d.ts +0 -50
- package/dist/model/strategy/adapter/walletPass/utils.js +0 -965
- package/dist/model/strategy/index.d.ts +0 -94
- package/dist/model/strategy/index.js +0 -551
- package/dist/model/strategy/strategy-example.d.ts +0 -5
- package/dist/model/strategy/strategy-example.js +0 -331
- package/dist/model/strategy/type.d.ts +0 -228
- package/dist/model/strategy/type.js +0 -94
- package/lib/model/index.d.ts +0 -1
- package/lib/model/index.js +0 -23
- package/lib/model/strategy/adapter/index.d.ts +0 -3
- package/lib/model/strategy/adapter/index.js +0 -45
- package/lib/model/strategy/adapter/type.d.ts +0 -28
- package/lib/model/strategy/adapter/type.js +0 -17
- package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +0 -84
- package/lib/model/strategy/adapter/walletPass/evaluator.js +0 -420
- package/lib/model/strategy/adapter/walletPass/example.d.ts +0 -4
- package/lib/model/strategy/adapter/walletPass/example.js +0 -207
- package/lib/model/strategy/adapter/walletPass/index.d.ts +0 -32
- package/lib/model/strategy/adapter/walletPass/index.js +0 -142
- package/lib/model/strategy/adapter/walletPass/locales.d.ts +0 -1
- package/lib/model/strategy/adapter/walletPass/locales.js +0 -51
- package/lib/model/strategy/adapter/walletPass/type.d.ts +0 -163
- package/lib/model/strategy/adapter/walletPass/type.js +0 -17
- package/lib/model/strategy/adapter/walletPass/utils.d.ts +0 -50
- package/lib/model/strategy/adapter/walletPass/utils.js +0 -660
- package/lib/model/strategy/index.d.ts +0 -94
- package/lib/model/strategy/index.js +0 -413
- package/lib/model/strategy/strategy-example.d.ts +0 -5
- package/lib/model/strategy/strategy-example.js +0 -318
- package/lib/model/strategy/type.d.ts +0 -228
- package/lib/model/strategy/type.js +0 -44
|
@@ -1,318 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
|
|
19
|
-
// src/model/strategy/strategy-example.ts
|
|
20
|
-
var strategy_example_exports = {};
|
|
21
|
-
__export(strategy_example_exports, {
|
|
22
|
-
runExamples: () => runExamples
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(strategy_example_exports);
|
|
25
|
-
var import_index = require("./index");
|
|
26
|
-
var voucherConfig = {
|
|
27
|
-
metadata: {
|
|
28
|
-
id: "VOUCHER_10",
|
|
29
|
-
name: "10元代金券",
|
|
30
|
-
type: "wallet_pass",
|
|
31
|
-
calculationType: "single"
|
|
32
|
-
},
|
|
33
|
-
conditions: {
|
|
34
|
-
operator: "and",
|
|
35
|
-
rules: [
|
|
36
|
-
{
|
|
37
|
-
type: "operator",
|
|
38
|
-
dimension: "scope_product",
|
|
39
|
-
field: "productId",
|
|
40
|
-
operator: "in",
|
|
41
|
-
value: [60734, 60735]
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
type: "operator",
|
|
45
|
-
dimension: "scope_channel",
|
|
46
|
-
field: "channel",
|
|
47
|
-
operator: "in",
|
|
48
|
-
value: ["pos", "mini_program"]
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
type: "operator",
|
|
52
|
-
dimension: "transaction",
|
|
53
|
-
field: "applicableProductTotal",
|
|
54
|
-
operator: ">=",
|
|
55
|
-
value: 100
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
type: "operator",
|
|
59
|
-
dimension: "limit_usage",
|
|
60
|
-
field: "perUserUsedCount",
|
|
61
|
-
operator: "<",
|
|
62
|
-
value: 1
|
|
63
|
-
}
|
|
64
|
-
],
|
|
65
|
-
actionIds: ["deduct_10"]
|
|
66
|
-
},
|
|
67
|
-
actions: [
|
|
68
|
-
{
|
|
69
|
-
id: "deduct_10",
|
|
70
|
-
type: "DEDUCT_AMOUNT",
|
|
71
|
-
value: 10,
|
|
72
|
-
valueType: "number",
|
|
73
|
-
valueUnit: "元",
|
|
74
|
-
target: "applicable_products",
|
|
75
|
-
priority: 1,
|
|
76
|
-
config: {
|
|
77
|
-
allowCrossProduct: true,
|
|
78
|
-
deductTaxAndFee: true
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
]
|
|
82
|
-
};
|
|
83
|
-
var voucherContext = {
|
|
84
|
-
entities: {
|
|
85
|
-
order: {
|
|
86
|
-
id: "ORDER_001",
|
|
87
|
-
total: 150,
|
|
88
|
-
items: [
|
|
89
|
-
{ productId: 60734, quantity: 2, price: 75 }
|
|
90
|
-
]
|
|
91
|
-
},
|
|
92
|
-
customer: {
|
|
93
|
-
id: "USER_001",
|
|
94
|
-
level: "vip"
|
|
95
|
-
}
|
|
96
|
-
},
|
|
97
|
-
attributes: {
|
|
98
|
-
productId: 60734,
|
|
99
|
-
channel: "pos",
|
|
100
|
-
applicableProductTotal: 150,
|
|
101
|
-
perUserUsedCount: 0
|
|
102
|
-
},
|
|
103
|
-
metadata: {
|
|
104
|
-
timestamp: Date.now(),
|
|
105
|
-
locale: "zh-CN"
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
var tieredDiscountConfig = {
|
|
109
|
-
metadata: {
|
|
110
|
-
id: "TIERED_DISCOUNT",
|
|
111
|
-
name: "阶梯满减",
|
|
112
|
-
type: "promotion",
|
|
113
|
-
calculationType: "single"
|
|
114
|
-
},
|
|
115
|
-
conditions: {
|
|
116
|
-
operator: "or",
|
|
117
|
-
rules: [
|
|
118
|
-
// 档位1:100-199 减10
|
|
119
|
-
{
|
|
120
|
-
operator: "and",
|
|
121
|
-
rules: [
|
|
122
|
-
{
|
|
123
|
-
type: "operator",
|
|
124
|
-
dimension: "transaction",
|
|
125
|
-
field: "orderTotal",
|
|
126
|
-
operator: ">=",
|
|
127
|
-
value: 100
|
|
128
|
-
},
|
|
129
|
-
{
|
|
130
|
-
type: "operator",
|
|
131
|
-
dimension: "transaction",
|
|
132
|
-
field: "orderTotal",
|
|
133
|
-
operator: "<",
|
|
134
|
-
value: 200
|
|
135
|
-
}
|
|
136
|
-
],
|
|
137
|
-
actionIds: ["deduct_10"]
|
|
138
|
-
},
|
|
139
|
-
// 档位2:200-299 减25
|
|
140
|
-
{
|
|
141
|
-
operator: "and",
|
|
142
|
-
rules: [
|
|
143
|
-
{
|
|
144
|
-
type: "operator",
|
|
145
|
-
dimension: "transaction",
|
|
146
|
-
field: "orderTotal",
|
|
147
|
-
operator: ">=",
|
|
148
|
-
value: 200
|
|
149
|
-
},
|
|
150
|
-
{
|
|
151
|
-
type: "operator",
|
|
152
|
-
dimension: "transaction",
|
|
153
|
-
field: "orderTotal",
|
|
154
|
-
operator: "<",
|
|
155
|
-
value: 300
|
|
156
|
-
}
|
|
157
|
-
],
|
|
158
|
-
actionIds: ["deduct_25"]
|
|
159
|
-
},
|
|
160
|
-
// 档位3:>= 300 减40
|
|
161
|
-
{
|
|
162
|
-
operator: "and",
|
|
163
|
-
rules: [
|
|
164
|
-
{
|
|
165
|
-
type: "operator",
|
|
166
|
-
dimension: "transaction",
|
|
167
|
-
field: "orderTotal",
|
|
168
|
-
operator: ">=",
|
|
169
|
-
value: 300
|
|
170
|
-
}
|
|
171
|
-
],
|
|
172
|
-
actionIds: ["deduct_40"]
|
|
173
|
-
}
|
|
174
|
-
],
|
|
175
|
-
actionIds: []
|
|
176
|
-
},
|
|
177
|
-
actions: [
|
|
178
|
-
{
|
|
179
|
-
id: "deduct_10",
|
|
180
|
-
type: "DEDUCT_AMOUNT",
|
|
181
|
-
value: 10,
|
|
182
|
-
target: "order",
|
|
183
|
-
priority: 1
|
|
184
|
-
},
|
|
185
|
-
{
|
|
186
|
-
id: "deduct_25",
|
|
187
|
-
type: "DEDUCT_AMOUNT",
|
|
188
|
-
value: 25,
|
|
189
|
-
target: "order",
|
|
190
|
-
priority: 2
|
|
191
|
-
},
|
|
192
|
-
{
|
|
193
|
-
id: "deduct_40",
|
|
194
|
-
type: "DEDUCT_AMOUNT",
|
|
195
|
-
value: 40,
|
|
196
|
-
target: "order",
|
|
197
|
-
priority: 3
|
|
198
|
-
}
|
|
199
|
-
]
|
|
200
|
-
};
|
|
201
|
-
var tieredContext = {
|
|
202
|
-
entities: {
|
|
203
|
-
order: { id: "ORDER_002", total: 250 }
|
|
204
|
-
},
|
|
205
|
-
attributes: {
|
|
206
|
-
orderTotal: 250
|
|
207
|
-
},
|
|
208
|
-
metadata: {
|
|
209
|
-
timestamp: Date.now()
|
|
210
|
-
}
|
|
211
|
-
};
|
|
212
|
-
var codeConditionConfig = {
|
|
213
|
-
metadata: {
|
|
214
|
-
id: "CODE_CONDITION_EXAMPLE",
|
|
215
|
-
name: "代码条件示例",
|
|
216
|
-
type: "custom"
|
|
217
|
-
},
|
|
218
|
-
conditions: {
|
|
219
|
-
operator: "and",
|
|
220
|
-
rules: [
|
|
221
|
-
// 使用 code 模式
|
|
222
|
-
{
|
|
223
|
-
type: "code",
|
|
224
|
-
code: 'attributes.orderTotal >= 100 && entities.customer.level === "vip"'
|
|
225
|
-
},
|
|
226
|
-
// 混合使用 operator 模式
|
|
227
|
-
{
|
|
228
|
-
type: "operator",
|
|
229
|
-
field: "productCount",
|
|
230
|
-
operator: ">=",
|
|
231
|
-
value: 2
|
|
232
|
-
}
|
|
233
|
-
],
|
|
234
|
-
actionIds: ["vip_discount"]
|
|
235
|
-
},
|
|
236
|
-
actions: [
|
|
237
|
-
{
|
|
238
|
-
id: "vip_discount",
|
|
239
|
-
type: "DISCOUNT_RATE",
|
|
240
|
-
value: 0.85,
|
|
241
|
-
target: "order",
|
|
242
|
-
priority: 1
|
|
243
|
-
}
|
|
244
|
-
]
|
|
245
|
-
};
|
|
246
|
-
var codeContext = {
|
|
247
|
-
entities: {
|
|
248
|
-
customer: { id: "USER_002", level: "vip" },
|
|
249
|
-
order: { id: "ORDER_003", total: 150 }
|
|
250
|
-
},
|
|
251
|
-
attributes: {
|
|
252
|
-
orderTotal: 150,
|
|
253
|
-
productCount: 3
|
|
254
|
-
},
|
|
255
|
-
metadata: {
|
|
256
|
-
timestamp: Date.now()
|
|
257
|
-
}
|
|
258
|
-
};
|
|
259
|
-
function runExamples() {
|
|
260
|
-
console.log("====== 策略模型使用示例 ======\n");
|
|
261
|
-
const engine = (0, import_index.createStrategyEngine)({
|
|
262
|
-
debug: true,
|
|
263
|
-
enableTrace: true
|
|
264
|
-
});
|
|
265
|
-
console.log("示例1: 10元代金券");
|
|
266
|
-
const result1 = engine.evaluate(voucherConfig, voucherContext);
|
|
267
|
-
console.log("结果:", JSON.stringify(result1, null, 2));
|
|
268
|
-
console.log("\n");
|
|
269
|
-
console.log("示例2: 阶梯满减(订单金额250)");
|
|
270
|
-
const result2 = engine.evaluate(tieredDiscountConfig, tieredContext);
|
|
271
|
-
console.log("结果:", JSON.stringify(result2, null, 2));
|
|
272
|
-
console.log("\n");
|
|
273
|
-
console.log("示例3: Code 模式条件");
|
|
274
|
-
const result3 = engine.evaluate(codeConditionConfig, codeContext);
|
|
275
|
-
console.log("结果:", JSON.stringify(result3, null, 2));
|
|
276
|
-
console.log("\n");
|
|
277
|
-
console.log("示例4: 快速评估");
|
|
278
|
-
const result4 = (0, import_index.evaluate)(voucherConfig, voucherContext);
|
|
279
|
-
console.log("适用:", result4.applicable);
|
|
280
|
-
console.log("匹配动作数:", result4.matchedActions.length);
|
|
281
|
-
console.log("\n");
|
|
282
|
-
console.log("示例5: 自定义运算符");
|
|
283
|
-
engine.registerOperator("divisible_by", (fieldValue, compareValue) => {
|
|
284
|
-
return Number(fieldValue) % Number(compareValue) === 0;
|
|
285
|
-
});
|
|
286
|
-
const customOperatorConfig = {
|
|
287
|
-
metadata: { id: "CUSTOM_OP", name: "自定义运算符", type: "test" },
|
|
288
|
-
conditions: {
|
|
289
|
-
operator: "and",
|
|
290
|
-
rules: [
|
|
291
|
-
{
|
|
292
|
-
type: "operator",
|
|
293
|
-
field: "amount",
|
|
294
|
-
operator: "divisible_by",
|
|
295
|
-
value: 10
|
|
296
|
-
}
|
|
297
|
-
],
|
|
298
|
-
actionIds: ["bonus"]
|
|
299
|
-
},
|
|
300
|
-
actions: [{ id: "bonus", type: "ADD_POINTS", value: 100, target: "customer" }]
|
|
301
|
-
};
|
|
302
|
-
const customContext = {
|
|
303
|
-
entities: {},
|
|
304
|
-
attributes: { amount: 50 },
|
|
305
|
-
metadata: { timestamp: Date.now() }
|
|
306
|
-
};
|
|
307
|
-
const result5 = engine.evaluate(customOperatorConfig, customContext);
|
|
308
|
-
console.log("结果:", result5.applicable ? "适用" : "不适用");
|
|
309
|
-
console.log("匹配动作:", result5.matchedActions);
|
|
310
|
-
console.log("\n引擎调试信息:", engine.getDebugInfo());
|
|
311
|
-
}
|
|
312
|
-
if (require.main === module) {
|
|
313
|
-
runExamples();
|
|
314
|
-
}
|
|
315
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
316
|
-
0 && (module.exports = {
|
|
317
|
-
runExamples
|
|
318
|
-
});
|
|
@@ -1,228 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 策略配置主结构
|
|
3
|
-
*/
|
|
4
|
-
export interface StrategyConfig<T = Record<string, any>> {
|
|
5
|
-
/** 元信息 */
|
|
6
|
-
metadata: StrategyMetadata<T>;
|
|
7
|
-
/** 条件组(可嵌套,每层可绑定动作) */
|
|
8
|
-
conditions: ConditionGroup;
|
|
9
|
-
/** 动作列表(带唯一ID) */
|
|
10
|
-
actions: ActionEffect[];
|
|
11
|
-
/** 展示配置(可选) */
|
|
12
|
-
display?: DisplayConfig;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* 策略元信息
|
|
16
|
-
*/
|
|
17
|
-
export interface StrategyMetadata<T = Record<string, any>> {
|
|
18
|
-
/** 策略ID */
|
|
19
|
-
id: string;
|
|
20
|
-
/** 策略名称 */
|
|
21
|
-
name: string | Record<string, string>;
|
|
22
|
-
/** 策略类型(完全可扩展) */
|
|
23
|
-
type: string;
|
|
24
|
-
/** 计算类型 */
|
|
25
|
-
calculationType?: 'single' | 'cumulative';
|
|
26
|
-
/** 版本 */
|
|
27
|
-
version?: string;
|
|
28
|
-
/** 描述 */
|
|
29
|
-
description?: string | Record<string, string>;
|
|
30
|
-
/** 自定义元数据 */
|
|
31
|
-
custom?: T;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* 条件组(支持嵌套)
|
|
35
|
-
*/
|
|
36
|
-
export interface ConditionGroup {
|
|
37
|
-
/** 逻辑运算符 */
|
|
38
|
-
operator: 'and' | 'or' | 'not';
|
|
39
|
-
/** 条件规则列表(可以是单条件或嵌套的条件组) */
|
|
40
|
-
rules: Array<ConditionRule | ConditionGroup>;
|
|
41
|
-
/** 关联的动作ID列表(必填,可以为空数组) */
|
|
42
|
-
actionIds: string[];
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* 条件规则(原子条件)
|
|
46
|
-
* 支持 code 模式使用 eval 执行
|
|
47
|
-
*/
|
|
48
|
-
export interface ConditionRule {
|
|
49
|
-
/** 类型 */
|
|
50
|
-
type: 'code' | 'operator';
|
|
51
|
-
/** 代码(code模式使用,使用eval执行) */
|
|
52
|
-
code?: string;
|
|
53
|
-
/** 维度(完全可扩展) */
|
|
54
|
-
dimension?: string;
|
|
55
|
-
/** 字段名 */
|
|
56
|
-
field?: string;
|
|
57
|
-
/** 运算符 */
|
|
58
|
-
operator?: string;
|
|
59
|
-
/** 比较值 */
|
|
60
|
-
value?: any;
|
|
61
|
-
/** 值类型 */
|
|
62
|
-
valueType?: 'number' | 'string' | 'boolean' | 'array' | 'object' | 'date';
|
|
63
|
-
/** 值单位 */
|
|
64
|
-
valueUnit?: string;
|
|
65
|
-
/** 额外配置 */
|
|
66
|
-
config?: Record<string, any>;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* 动作效果
|
|
70
|
-
*/
|
|
71
|
-
export interface ActionEffect {
|
|
72
|
-
/** 动作的唯一标识 */
|
|
73
|
-
id: string;
|
|
74
|
-
/** 效果类型(完全可扩展) */
|
|
75
|
-
type: string;
|
|
76
|
-
/** 运算符(可选) */
|
|
77
|
-
operator?: string;
|
|
78
|
-
/** 值 */
|
|
79
|
-
value: any;
|
|
80
|
-
/** 值类型 */
|
|
81
|
-
valueType?: 'number' | 'string' | 'boolean' | 'array' | 'object';
|
|
82
|
-
/** 值单位 */
|
|
83
|
-
valueUnit?: string;
|
|
84
|
-
/** 作用目标 */
|
|
85
|
-
target: string;
|
|
86
|
-
/** 优先级(数字越大优先级越高) */
|
|
87
|
-
priority?: number;
|
|
88
|
-
/** 配置(完全可扩展) */
|
|
89
|
-
config?: Record<string, any>;
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* 展示配置
|
|
93
|
-
*/
|
|
94
|
-
export interface DisplayConfig {
|
|
95
|
-
/** 商品卡片展示 */
|
|
96
|
-
productCard?: {
|
|
97
|
-
text: string | Record<string, string>;
|
|
98
|
-
type: 'tag' | 'badge' | 'label';
|
|
99
|
-
image?: string;
|
|
100
|
-
style?: Record<string, any>;
|
|
101
|
-
};
|
|
102
|
-
/** 详情页展示 */
|
|
103
|
-
detail?: {
|
|
104
|
-
title: string | Record<string, string>;
|
|
105
|
-
description: string | Record<string, string>;
|
|
106
|
-
image?: string;
|
|
107
|
-
};
|
|
108
|
-
/** 自定义展示配置 */
|
|
109
|
-
custom?: Record<string, any>;
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* 运行时上下文结构
|
|
113
|
-
*/
|
|
114
|
-
export interface RuntimeContext {
|
|
115
|
-
/** 实体数据(完全开放,由业务层定义) */
|
|
116
|
-
entities: Record<string, any>;
|
|
117
|
-
/** 属性数据(扁平化的计算值,用于条件判断) */
|
|
118
|
-
attributes: Record<string, any>;
|
|
119
|
-
/** 上下文元数据 */
|
|
120
|
-
metadata: ContextMetadata;
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* 上下文元数据
|
|
124
|
-
*/
|
|
125
|
-
export interface ContextMetadata {
|
|
126
|
-
/** 请求ID(用于追踪) */
|
|
127
|
-
requestId?: string;
|
|
128
|
-
/** 时间戳 */
|
|
129
|
-
timestamp: number;
|
|
130
|
-
/** 语言 */
|
|
131
|
-
locale?: string;
|
|
132
|
-
/** 自定义元数据 */
|
|
133
|
-
custom?: Record<string, any>;
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* 评估结果结构
|
|
137
|
-
*/
|
|
138
|
-
export interface EvaluationResult {
|
|
139
|
-
/** 是否成功执行(引擎层面) */
|
|
140
|
-
success: boolean;
|
|
141
|
-
/** 策略是否适用(业务层面) */
|
|
142
|
-
applicable: boolean;
|
|
143
|
-
/** 结果码 */
|
|
144
|
-
code: string;
|
|
145
|
-
/** 消息(多语言key或直接文本) */
|
|
146
|
-
message?: string;
|
|
147
|
-
/** 匹配信息 */
|
|
148
|
-
matched: MatchedInfo;
|
|
149
|
-
/** 匹配的动作列表(按priority排序) */
|
|
150
|
-
matchedActions: ActionEffect[];
|
|
151
|
-
/** 输出结果(完全开放,由适配器定义) */
|
|
152
|
-
outputs: Record<string, any>;
|
|
153
|
-
/** 执行轨迹(可选,用于调试) */
|
|
154
|
-
trace?: ExecutionTrace;
|
|
155
|
-
/** 策略配置 */
|
|
156
|
-
config: StrategyConfig;
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* 匹配信息
|
|
160
|
-
*/
|
|
161
|
-
export interface MatchedInfo {
|
|
162
|
-
/** 条件是否满足 */
|
|
163
|
-
conditions: boolean;
|
|
164
|
-
/** 收集到的 actionIds */
|
|
165
|
-
actionIds: string[];
|
|
166
|
-
/** 详细匹配信息 */
|
|
167
|
-
details: Record<string, any>;
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* 执行轨迹
|
|
171
|
-
*/
|
|
172
|
-
export interface ExecutionTrace {
|
|
173
|
-
/** 执行步骤 */
|
|
174
|
-
steps: TraceStep[];
|
|
175
|
-
/** 总耗时(毫秒) */
|
|
176
|
-
duration: number;
|
|
177
|
-
/** 错误信息 */
|
|
178
|
-
errors?: Array<{
|
|
179
|
-
step: string;
|
|
180
|
-
error: string;
|
|
181
|
-
timestamp: number;
|
|
182
|
-
}>;
|
|
183
|
-
}
|
|
184
|
-
/**
|
|
185
|
-
* 追踪步骤
|
|
186
|
-
*/
|
|
187
|
-
export interface TraceStep {
|
|
188
|
-
/** 步骤名称 */
|
|
189
|
-
step: string;
|
|
190
|
-
/** 步骤状态 */
|
|
191
|
-
status: 'success' | 'failed' | 'skipped';
|
|
192
|
-
/** 耗时(毫秒) */
|
|
193
|
-
duration: number;
|
|
194
|
-
/** 详细信息 */
|
|
195
|
-
details?: Record<string, any>;
|
|
196
|
-
}
|
|
197
|
-
/** 成功码 */
|
|
198
|
-
export declare const SUCCESS_CODES: {
|
|
199
|
-
readonly SUCCESS: "SUCCESS";
|
|
200
|
-
};
|
|
201
|
-
/** 不适用码 */
|
|
202
|
-
export declare const NOT_APPLICABLE_CODES: {
|
|
203
|
-
readonly CONDITION_NOT_MET: "CONDITION_NOT_MET";
|
|
204
|
-
};
|
|
205
|
-
/** 错误码 */
|
|
206
|
-
export declare const ERROR_CODES: {
|
|
207
|
-
readonly INVALID_CONFIG: "INVALID_CONFIG";
|
|
208
|
-
readonly INVALID_CONTEXT: "INVALID_CONTEXT";
|
|
209
|
-
readonly EVALUATION_ERROR: "EVALUATION_ERROR";
|
|
210
|
-
readonly UNKNOWN_ERROR: "UNKNOWN_ERROR";
|
|
211
|
-
};
|
|
212
|
-
/**
|
|
213
|
-
* 引擎配置选项
|
|
214
|
-
*/
|
|
215
|
-
export interface EngineOptions {
|
|
216
|
-
/** 是否启用调试模式 */
|
|
217
|
-
debug?: boolean;
|
|
218
|
-
/** 是否启用追踪 */
|
|
219
|
-
enableTrace?: boolean;
|
|
220
|
-
/** 运算符处理器映射 */
|
|
221
|
-
operatorHandlers?: Record<string, OperatorHandler>;
|
|
222
|
-
/** 自定义错误处理器 */
|
|
223
|
-
errorHandler?: (error: Error, context: RuntimeContext) => void;
|
|
224
|
-
}
|
|
225
|
-
/**
|
|
226
|
-
* 运算符处理器
|
|
227
|
-
*/
|
|
228
|
-
export type OperatorHandler = (fieldValue: any, compareValue: any, rule: ConditionRule) => boolean;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
|
|
19
|
-
// src/model/strategy/type.ts
|
|
20
|
-
var type_exports = {};
|
|
21
|
-
__export(type_exports, {
|
|
22
|
-
ERROR_CODES: () => ERROR_CODES,
|
|
23
|
-
NOT_APPLICABLE_CODES: () => NOT_APPLICABLE_CODES,
|
|
24
|
-
SUCCESS_CODES: () => SUCCESS_CODES
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(type_exports);
|
|
27
|
-
var SUCCESS_CODES = {
|
|
28
|
-
SUCCESS: "SUCCESS"
|
|
29
|
-
};
|
|
30
|
-
var NOT_APPLICABLE_CODES = {
|
|
31
|
-
CONDITION_NOT_MET: "CONDITION_NOT_MET"
|
|
32
|
-
};
|
|
33
|
-
var ERROR_CODES = {
|
|
34
|
-
INVALID_CONFIG: "INVALID_CONFIG",
|
|
35
|
-
INVALID_CONTEXT: "INVALID_CONTEXT",
|
|
36
|
-
EVALUATION_ERROR: "EVALUATION_ERROR",
|
|
37
|
-
UNKNOWN_ERROR: "UNKNOWN_ERROR"
|
|
38
|
-
};
|
|
39
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
40
|
-
0 && (module.exports = {
|
|
41
|
-
ERROR_CODES,
|
|
42
|
-
NOT_APPLICABLE_CODES,
|
|
43
|
-
SUCCESS_CODES
|
|
44
|
-
});
|