@etsoo/appscript 1.6.56 → 1.6.58

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.
@@ -1,368 +0,0 @@
1
- import { DataTypes, IStorage, IdType } from "@etsoo/shared";
2
- import { Currency } from "./Currency";
3
- /**
4
- * Shopping cart owner
5
- * 购物篮所有人
6
- */
7
- export type ShoppingCartOwner = DataTypes.IdNameItem & {
8
- culture?: string;
9
- currency?: Currency;
10
- };
11
- /**
12
- * Shopping cart data
13
- * 购物篮数据
14
- */
15
- export type ShoppingCartData<T extends ShoppingCartItem> = {
16
- culture: string;
17
- currency: Currency;
18
- owner: ShoppingCartOwner;
19
- items: T[];
20
- promotions: ShoppingPromotion[];
21
- formData?: any;
22
- cache?: Record<string, unknown>;
23
- };
24
- /**
25
- * Shopping promotion
26
- * 购物促销
27
- */
28
- export type ShoppingPromotion = {
29
- /**
30
- * Promotion id
31
- * 促销编号
32
- */
33
- id: number;
34
- /**
35
- * Promotion title
36
- * 促销标题
37
- */
38
- title: string;
39
- /**
40
- * Discount amount
41
- * 折扣金额
42
- */
43
- amount: number;
44
- };
45
- /**
46
- * Shopping cart base item
47
- * 购物篮基础项目
48
- */
49
- export type ShoppingCartItemBase = {
50
- /**
51
- * Product id
52
- * 产品编号
53
- */
54
- id: IdType;
55
- /**
56
- * Product title, default is name
57
- * 产品标题,默认为name
58
- */
59
- title?: string;
60
- /**
61
- * Sale price
62
- * 销售价格
63
- */
64
- price: number;
65
- /**
66
- * Qty
67
- * 数量
68
- */
69
- qty: number;
70
- /**
71
- * Asset qty
72
- */
73
- assetQty?: number;
74
- /**
75
- * Product level promotions
76
- * 产品层次促销
77
- */
78
- promotions: ShoppingPromotion[];
79
- };
80
- /**
81
- * Shopping cart item
82
- * 购物篮项目
83
- */
84
- export type ShoppingCartItem = ShoppingCartItemBase & {
85
- /**
86
- * Product name
87
- * 产品名称
88
- */
89
- name: string;
90
- /**
91
- * Current price for cache
92
- * 当前缓存价格
93
- */
94
- currentPrice?: number;
95
- /**
96
- * Subtotal
97
- * 小计
98
- */
99
- subtotal: number;
100
- /**
101
- * Total discount amount
102
- * 总折扣金额
103
- */
104
- discount: number;
105
- };
106
- /**
107
- * Shopping cart change reason
108
- * 购物篮改变原因
109
- */
110
- export type ShoppingCartChangeReason = "add" | "clear" | "remove" | "title" | "update";
111
- /**
112
- * Shopping cart
113
- * 购物篮
114
- */
115
- export declare class ShoppingCart<T extends ShoppingCartItem> {
116
- private readonly storage;
117
- /**
118
- * Create identifier key
119
- * 创建识别键
120
- * @param currency Currency
121
- * @param culture Culture
122
- * @param key Additional key
123
- * @returns Result
124
- */
125
- static createKey(currency: Currency, culture: string, key: string): string;
126
- /**
127
- * Clear shopping cart
128
- * 清除购物篮
129
- * @param identifier Identifier
130
- * @param storage Storage
131
- */
132
- static clear(identifier: string, storage: IStorage): void;
133
- /**
134
- * Get cart data
135
- * 获取购物篮数据
136
- * @param storage Storage
137
- * @param id Cart id
138
- * @returns Result
139
- */
140
- static getCartData<D extends ShoppingCartItem>(storage: IStorage, id: string): ShoppingCartData<D> | undefined;
141
- /**
142
- * Owner data
143
- * 所有者信息
144
- */
145
- owner?: ShoppingCartOwner;
146
- _currency: Currency;
147
- /**
148
- * ISO currency id
149
- * 标准货币编号
150
- */
151
- get currency(): Currency;
152
- private set currency(value);
153
- _culture: string;
154
- /**
155
- * ISO culture id, like zh-Hans
156
- * 标准语言文化编号
157
- */
158
- get culture(): string;
159
- private set culture(value);
160
- _items: T[];
161
- /**
162
- * Items
163
- * 项目
164
- */
165
- get items(): T[];
166
- private set items(value);
167
- _promotions: ShoppingPromotion[];
168
- /**
169
- * Order level promotions
170
- * 订单层面促销
171
- */
172
- get promotions(): ShoppingPromotion[];
173
- private set promotions(value);
174
- /**
175
- * Related form data
176
- * 关联的表单数据
177
- */
178
- formData: any;
179
- /**
180
- * Cache
181
- * 缓存对象
182
- */
183
- cache?: Record<string, unknown>;
184
- _symbol: string | undefined;
185
- /**
186
- * Currency symbol
187
- * 币种符号
188
- */
189
- get symbol(): string | undefined;
190
- private set symbol(value);
191
- /**
192
- * Key for identifier
193
- */
194
- readonly key: string;
195
- /**
196
- * Cart identifier
197
- * 购物篮标识
198
- */
199
- get identifier(): string;
200
- /**
201
- * All data keys
202
- * 所有的数据键
203
- */
204
- get keys(): string[];
205
- set keys(items: string[]);
206
- /**
207
- * Lines count
208
- * 项目数量
209
- */
210
- get lines(): number;
211
- /**
212
- * Total qty
213
- * 总数量
214
- */
215
- get totalQty(): number;
216
- /**
217
- * Total amount
218
- * 总金额
219
- */
220
- get totalAmount(): number;
221
- /**
222
- * Total amount string
223
- * 总金额字符串
224
- */
225
- get totalAmountStr(): string;
226
- /**
227
- * Cached prices
228
- * 缓存的价格
229
- */
230
- private prices;
231
- /**
232
- * Onchange callback
233
- * 改变时回调
234
- */
235
- onChange?: (reason: ShoppingCartChangeReason, changedItems: T[]) => void;
236
- /**
237
- * Constructor
238
- * 构造函数
239
- * @param key Key for identifier
240
- * @param init Currency & culture ISO code array
241
- * @param storage Data storage
242
- */
243
- constructor(key: string, init: [Currency, string], storage?: IStorage);
244
- /**
245
- * Constructor
246
- * 构造函数
247
- * @param key Key for identifier
248
- * @param state Initialization state
249
- * @param storage Data storage
250
- */
251
- constructor(key: string, state: ShoppingCartData<T>, storage?: IStorage);
252
- private getCartData;
253
- private setCartData;
254
- private doChange;
255
- /**
256
- * Add item
257
- * 添加项目
258
- * @param item New item
259
- */
260
- addItem(item: T): void;
261
- /**
262
- * Add items
263
- * @param items New items
264
- */
265
- addItems(items: T[]): void;
266
- /**
267
- * Cache price
268
- * @param id Item id
269
- * @param price Price
270
- * @param overrideExisting Override existing price
271
- */
272
- cachePrice(id: T["id"], price: number, overrideExisting?: boolean): void;
273
- /**
274
- * Change currency
275
- * @param currency Currency
276
- */
277
- changeCurrency(currency: Currency): void;
278
- /**
279
- * Change culture
280
- * @param culture Culture
281
- */
282
- changeCulture(culture: string): void;
283
- /**
284
- * Clear storage
285
- * @param keepOwner Keep owner data
286
- */
287
- clear(keepOwner?: boolean): void;
288
- /**
289
- * Format amount
290
- * @param amount Amount
291
- * @returns Result
292
- */
293
- formatAmount(amount: number): string;
294
- /**
295
- * Get item
296
- * @param id Item id
297
- * @returns Result
298
- */
299
- getItem(id: T["id"]): T | undefined;
300
- /**
301
- * Push item
302
- * 推送项目
303
- * @param data Item data
304
- * @returns Added or not
305
- */
306
- pushItem(data: T): boolean;
307
- /**
308
- * Reset currency and culture
309
- * @param currency New currency
310
- * @param culture New culture
311
- */
312
- reset(currency: Currency, culture: string): void;
313
- /**
314
- * Remove item from the index
315
- * @param index Item index
316
- */
317
- removeItem(index: number): void;
318
- /**
319
- * Reset item
320
- * @param item Shopping cart item
321
- */
322
- resetItem(item: ShoppingCartItem): void;
323
- /**
324
- * Save cart data
325
- * @param persisted For persisted storage
326
- */
327
- save(persisted?: boolean): ShoppingCartData<T> | undefined;
328
- /**
329
- * Trigger update
330
- * 触发更新
331
- */
332
- update(): void;
333
- /**
334
- * Update discount
335
- * @param item Shopping cart item
336
- */
337
- updateDiscount(item: ShoppingCartItem): void;
338
- /**
339
- * Update asset item
340
- * 更新资产项目
341
- * @param id Product id
342
- * @param qty Asset qty
343
- * @param itemCreator New item creator
344
- * @returns Updated or not
345
- */
346
- updateAssetItem(id: T["id"], assetQty: number | undefined, itemCreator?: () => Omit<T, "id" | "price" | "assetQty" | "subtotal" | "discount" | "promotions">): boolean;
347
- /**
348
- * Update item
349
- * 更新项目
350
- * @param id Product id
351
- * @param qty Qty
352
- * @param itemCreator New item creator
353
- * @returns Updated or not
354
- */
355
- updateItem(id: T["id"], qty: number | undefined, itemCreator?: () => Omit<T, "id" | "price" | "qty" | "subtotal" | "discount" | "promotions">): boolean;
356
- /**
357
- * Update price
358
- * @param id Item id
359
- * @param price New price
360
- */
361
- updatePrice(id: T["id"], price: number): void;
362
- /**
363
- * Update title
364
- * @param id Item id
365
- * @param title New title
366
- */
367
- updateTitle(id: T["id"], title: string): void;
368
- }