b23-lib 3.8.0 → 3.9.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 (102) hide show
  1. package/dist/Auth/index.js +1 -1
  2. package/dist/Auth/index.js.map +1 -1
  3. package/dist/Auth/index.mjs +1 -1
  4. package/dist/Auth/index.mjs.map +1 -1
  5. package/dist/Classes/Cart.d.mts +1 -2
  6. package/dist/Classes/Cart.d.ts +1 -2
  7. package/dist/Classes/Cart.js +1 -1
  8. package/dist/Classes/Cart.js.map +1 -1
  9. package/dist/Classes/Cart.mjs +1 -1
  10. package/dist/Classes/Cart.mjs.map +1 -1
  11. package/dist/Classes/Charge.js +1 -1
  12. package/dist/Classes/Charge.js.map +1 -1
  13. package/dist/Classes/Charge.mjs +1 -1
  14. package/dist/Classes/Coupon.js +1 -1
  15. package/dist/Classes/Coupon.js.map +1 -1
  16. package/dist/Classes/Coupon.mjs +1 -1
  17. package/dist/Classes/Error.d.mts +4 -1
  18. package/dist/Classes/Error.d.ts +4 -1
  19. package/dist/Classes/Error.js +1 -1
  20. package/dist/Classes/Error.js.map +1 -1
  21. package/dist/Classes/Error.mjs +1 -1
  22. package/dist/Classes/ImageInfo.js.map +1 -1
  23. package/dist/Classes/ImageInfo.mjs +1 -1
  24. package/dist/Classes/Inventory.d.mts +1 -2
  25. package/dist/Classes/Inventory.d.ts +1 -2
  26. package/dist/Classes/Inventory.js +1 -1
  27. package/dist/Classes/Inventory.js.map +1 -1
  28. package/dist/Classes/Inventory.mjs +1 -1
  29. package/dist/Classes/Inventory.mjs.map +1 -1
  30. package/dist/Classes/Invoice.d.mts +1 -2
  31. package/dist/Classes/Invoice.d.ts +1 -2
  32. package/dist/Classes/Invoice.js.map +1 -1
  33. package/dist/Classes/Invoice.mjs +1 -1
  34. package/dist/Classes/LineItem.d.mts +1 -2
  35. package/dist/Classes/LineItem.d.ts +1 -2
  36. package/dist/Classes/LineItem.js +1 -1
  37. package/dist/Classes/LineItem.js.map +1 -1
  38. package/dist/Classes/LineItem.mjs +1 -1
  39. package/dist/Classes/Order.d.mts +1 -2
  40. package/dist/Classes/Order.d.ts +1 -2
  41. package/dist/Classes/Order.js +1 -1
  42. package/dist/Classes/Order.js.map +1 -1
  43. package/dist/Classes/Order.mjs +1 -1
  44. package/dist/Classes/Order.mjs.map +1 -1
  45. package/dist/Classes/Price.js.map +1 -1
  46. package/dist/Classes/Price.mjs +1 -1
  47. package/dist/Classes/Product.d.mts +5 -257
  48. package/dist/Classes/Product.d.ts +5 -257
  49. package/dist/Classes/Product.js +1 -1
  50. package/dist/Classes/Product.js.map +1 -1
  51. package/dist/Classes/Product.mjs +1 -1
  52. package/dist/Classes/ShoppingContainer.d.mts +1 -2
  53. package/dist/Classes/ShoppingContainer.d.ts +1 -2
  54. package/dist/Classes/ShoppingContainer.js +1 -1
  55. package/dist/Classes/ShoppingContainer.js.map +1 -1
  56. package/dist/Classes/ShoppingContainer.mjs +1 -1
  57. package/dist/Classes/TaxRule.js +1 -1
  58. package/dist/Classes/TaxRule.js.map +1 -1
  59. package/dist/Classes/TaxRule.mjs +1 -1
  60. package/dist/Classes/TieredPrice.d.mts +5 -81
  61. package/dist/Classes/TieredPrice.d.ts +5 -81
  62. package/dist/Classes/TieredPrice.js +1 -1
  63. package/dist/Classes/TieredPrice.js.map +1 -1
  64. package/dist/Classes/TieredPrice.mjs +1 -1
  65. package/dist/Product-BywRotdH.d.mts +367 -0
  66. package/dist/Product-mtVUKzNI.d.ts +367 -0
  67. package/dist/chunk-4QU5WW6U.mjs +2 -0
  68. package/dist/chunk-4QU5WW6U.mjs.map +1 -0
  69. package/dist/chunk-7B5TAYNA.mjs +2 -0
  70. package/dist/chunk-7B5TAYNA.mjs.map +1 -0
  71. package/dist/{chunk-2B2XI6FG.mjs → chunk-7RAIVZKB.mjs} +2 -2
  72. package/dist/{chunk-2B2XI6FG.mjs.map → chunk-7RAIVZKB.mjs.map} +1 -1
  73. package/dist/{chunk-C3METQSR.mjs → chunk-EZ35IKUA.mjs} +2 -2
  74. package/dist/{chunk-C3METQSR.mjs.map → chunk-EZ35IKUA.mjs.map} +1 -1
  75. package/dist/{chunk-TU4HOP63.mjs → chunk-MPKIC2MS.mjs} +2 -2
  76. package/dist/{chunk-TU4HOP63.mjs.map → chunk-MPKIC2MS.mjs.map} +1 -1
  77. package/dist/{chunk-R5DM7WCD.mjs → chunk-O6BLQQO7.mjs} +2 -2
  78. package/dist/chunk-O6BLQQO7.mjs.map +1 -0
  79. package/dist/chunk-PNTRHKEH.mjs +2 -0
  80. package/dist/chunk-PNTRHKEH.mjs.map +1 -0
  81. package/dist/{chunk-PAOHRZCC.mjs → chunk-Q7FOHAQD.mjs} +2 -2
  82. package/dist/{chunk-PAOHRZCC.mjs.map → chunk-Q7FOHAQD.mjs.map} +1 -1
  83. package/dist/{chunk-AWKAKL2Y.mjs → chunk-REP6D3WD.mjs} +2 -2
  84. package/dist/{chunk-AWKAKL2Y.mjs.map → chunk-REP6D3WD.mjs.map} +1 -1
  85. package/dist/{chunk-VO7ZE5C3.mjs → chunk-UIQH5QIR.mjs} +2 -2
  86. package/dist/{chunk-VO7ZE5C3.mjs.map → chunk-UIQH5QIR.mjs.map} +1 -1
  87. package/dist/index.d.mts +1 -2
  88. package/dist/index.d.ts +1 -2
  89. package/dist/index.js +2 -2
  90. package/dist/index.js.map +1 -1
  91. package/dist/index.mjs +1 -1
  92. package/dist/index.mjs.map +1 -1
  93. package/package.json +1 -1
  94. package/dist/chunk-DURMXVHZ.mjs +0 -2
  95. package/dist/chunk-DURMXVHZ.mjs.map +0 -1
  96. package/dist/chunk-ID3CEA7W.mjs +0 -2
  97. package/dist/chunk-ID3CEA7W.mjs.map +0 -1
  98. package/dist/chunk-LJEJAR35.mjs +0 -2
  99. package/dist/chunk-LJEJAR35.mjs.map +0 -1
  100. package/dist/chunk-R5DM7WCD.mjs.map +0 -1
  101. package/dist/chunk-USMLRWT6.mjs +0 -2
  102. package/dist/chunk-USMLRWT6.mjs.map +0 -1
@@ -0,0 +1,367 @@
1
+ import BaseModel, { BaseAttributes } from './Classes/Base.mjs';
2
+ import { a as PriceModel, P as PriceData, b as Prettify, c as CurrencyCode, f as Color, d as LocalizedString, C as CountryCode, e as LocalizedValue, L as LocaleCode } from './Common-BqhQxCq8.mjs';
3
+ import { GenderCategory, ProductType, ImageCategory } from './Classes/Enum.mjs';
4
+ import ImageInfoModel, { ImageInfoData } from './Classes/ImageInfo.mjs';
5
+
6
+ declare enum PricingType {
7
+ VOLUME = "volume",
8
+ SELECTION = "selection"
9
+ }
10
+ /**
11
+ * Represents a pricing tier based on a minimum purchase quantity.
12
+ */
13
+ type PriceTier = {
14
+ enabled: boolean;
15
+ minQuantity: number;
16
+ unitPrice: PriceModel;
17
+ };
18
+ type PriceTierData = {
19
+ enabled: boolean;
20
+ minQuantity: number;
21
+ unitPrice: PriceData;
22
+ };
23
+ /**
24
+ * Represents the configuration for a specific selection variant.
25
+ */
26
+ type SelectionPricingData = {
27
+ selectionAttributes: SelectionAttributes;
28
+ baseUnitPrice: PriceData;
29
+ tiers?: PriceTierData[];
30
+ };
31
+ type SelectionPricing = {
32
+ selectionAttributes: SelectionAttributes;
33
+ baseUnitPrice: PriceModel;
34
+ tiers: PriceTier[];
35
+ };
36
+ type PriceTierAttributes = Prettify<Omit<PriceTierData, 'enabled'> & {
37
+ enabled?: boolean;
38
+ }>;
39
+ /**
40
+ * Represents the attributes required for tiered pricing.
41
+ */
42
+ type TieredPriceAttributes = Prettify<{
43
+ taxCategory: string;
44
+ isTaxInclusive?: boolean;
45
+ } & ({
46
+ currency?: CurrencyCode;
47
+ type?: PricingType.VOLUME;
48
+ baseUnitPrice: PriceData;
49
+ tiers?: PriceTierAttributes[];
50
+ } | {
51
+ currency: CurrencyCode;
52
+ type: PricingType.SELECTION;
53
+ selections: (Omit<SelectionPricingData, 'tiers'> & {
54
+ tiers?: PriceTierAttributes[];
55
+ })[];
56
+ })>;
57
+ type TieredPriceData = Prettify<{
58
+ taxCategory: string;
59
+ isTaxInclusive: boolean;
60
+ currency: CurrencyCode;
61
+ } & ({
62
+ type?: PricingType.VOLUME;
63
+ baseUnitPrice: PriceData;
64
+ tiers: PriceTierData[];
65
+ } | {
66
+ type: PricingType.SELECTION;
67
+ selections: SelectionPricingData[];
68
+ })>;
69
+ declare abstract class TieredPriceModel {
70
+ protected type: PricingType;
71
+ protected taxCategory: string;
72
+ protected isTaxInclusive: boolean;
73
+ /**
74
+ * Factory method to instantiate the correct concrete TieredPriceModel implementation.
75
+ */
76
+ static create(data: TieredPriceAttributes): TieredPriceModel;
77
+ constructor(data: TieredPriceAttributes);
78
+ getType(): PricingType;
79
+ getTaxCategory(): string;
80
+ getIsTaxInclusive(): boolean;
81
+ abstract getBaseUnitPrice(selectionAttributes?: SelectionAttributes): PriceModel;
82
+ abstract getDetails(): TieredPriceData;
83
+ abstract getCurrency(): string;
84
+ abstract getApplicableUnitPrice(quantity: number, selectionAttributes?: SelectionAttributes): PriceModel;
85
+ abstract getMinQuantity(selectionAttributes?: SelectionAttributes): number;
86
+ abstract getMaxDiscountPercent(selectionAttributes?: SelectionAttributes): number;
87
+ }
88
+ declare class VolumeTieredPriceModel extends TieredPriceModel {
89
+ protected baseUnitPrice: PriceModel;
90
+ protected tiers: PriceTier[];
91
+ protected currency: CurrencyCode;
92
+ constructor(data: Extract<TieredPriceAttributes, {
93
+ type?: PricingType.VOLUME;
94
+ }>);
95
+ getBaseUnitPrice(): PriceModel;
96
+ getCurrency(): string;
97
+ getApplicableUnitPrice(quantity: number): PriceModel;
98
+ getMinQuantity(): number;
99
+ getMaxDiscountPercent(): number;
100
+ getDetails(): TieredPriceData;
101
+ }
102
+ declare class SelectionTieredPriceModel extends TieredPriceModel {
103
+ protected currency: CurrencyCode;
104
+ protected selections: SelectionPricing[];
105
+ constructor(data: Extract<TieredPriceAttributes, {
106
+ type: PricingType.SELECTION;
107
+ }>);
108
+ protected findMatch(selectionAttributes: SelectionAttributes): SelectionPricing;
109
+ getBaseUnitPrice(selectionAttributes?: SelectionAttributes): PriceModel;
110
+ getCurrency(): string;
111
+ getApplicableUnitPrice(quantity: number, selectionAttributes?: SelectionAttributes): PriceModel;
112
+ getMinQuantity(selectionAttributes?: SelectionAttributes): number;
113
+ getMaxDiscountPercent(selectionAttributes?: SelectionAttributes): number;
114
+ getDetails(): TieredPriceData;
115
+ }
116
+
117
+ type ProductSelectionAttributes = Prettify<{
118
+ color: Color[];
119
+ size: string[];
120
+ } & {
121
+ [key: string]: string | string[] | Color[];
122
+ }>;
123
+ type SelectionAttributes = {
124
+ color: Color;
125
+ [key: string]: string | Color;
126
+ };
127
+ type VariantData = {
128
+ sku: string;
129
+ selectionAttributes: SelectionAttributes;
130
+ images: {
131
+ primary: ImageInfoData;
132
+ gallery: ImageInfoData[];
133
+ };
134
+ };
135
+ type VariantModel = {
136
+ sku: string;
137
+ selectionAttributes: SelectionAttributes;
138
+ images: {
139
+ primary: ImageInfoModel;
140
+ gallery: ImageInfoModel[];
141
+ };
142
+ };
143
+ type ProductSpecification = {
144
+ [key: string]: string | string[];
145
+ };
146
+ type ProductAttributes = BaseAttributes & {
147
+ id: string;
148
+ key: string;
149
+ name: LocalizedString;
150
+ description: LocalizedString;
151
+ slug: LocalizedString;
152
+ brand: string;
153
+ pricing: {
154
+ [country in CountryCode]?: TieredPriceAttributes;
155
+ };
156
+ targetGender: GenderCategory;
157
+ attributes: ProductSelectionAttributes;
158
+ specifications: LocalizedValue<ProductSpecification>;
159
+ categories: string[];
160
+ productType?: ProductType;
161
+ variants: VariantData[];
162
+ isActive: boolean;
163
+ searchTags?: LocalizedValue<string[]>;
164
+ };
165
+ type ProductData = Required<ProductAttributes>;
166
+ declare class ProductModel extends BaseModel {
167
+ protected id: string;
168
+ protected key: string;
169
+ protected name: LocalizedString;
170
+ protected description: LocalizedString;
171
+ protected slug: LocalizedString;
172
+ protected brand: string;
173
+ protected pricing: {
174
+ [country in CountryCode]?: TieredPriceModel;
175
+ };
176
+ protected variants: VariantModel[];
177
+ protected targetGender: GenderCategory;
178
+ protected attributes: ProductSelectionAttributes;
179
+ protected specifications: LocalizedValue<ProductSpecification>;
180
+ protected categories: string[];
181
+ protected productType: ProductType;
182
+ protected isActive: boolean;
183
+ protected searchTags: LocalizedValue<string[]>;
184
+ static productKeyRegex: RegExp;
185
+ static productSKURegex: RegExp;
186
+ /**
187
+ * Generates a unique key for checking uniqueness for a given selection attributes.
188
+ * Excludes 'size' from the key generation.
189
+ * @param selectionAttributes - The selection attributes.
190
+ * @returns A string key representing the unique attribute combination.
191
+ */
192
+ static generateSelectionAttributesKey(selectionAttributes: SelectionAttributes): string;
193
+ /**
194
+ * Parses a selection attributes key into an object.
195
+ * @param key - The selection attributes key to parse.
196
+ * @returns An object containing the parsed selection attributes.
197
+ */
198
+ static parseSelectionAttributesKey(key: string): SelectionAttributes;
199
+ /**
200
+ * Creates an instance of ProductModel.
201
+ * Initializes properties based on the provided data, creating copies where necessary.
202
+ * @param data - The initial product attributes.
203
+ * @param date - Optional date for setting creation/modification times (defaults to now).
204
+ */
205
+ constructor(data: ProductAttributes, date?: Date);
206
+ /**
207
+ * Gets the base Product ID.
208
+ * @returns Product ID.
209
+ */
210
+ getId(): string;
211
+ /**
212
+ * Gets the user-friendly product key.
213
+ * @returns Product Key.
214
+ */
215
+ getKey(): string;
216
+ /**
217
+ * Gets the full localized product name object.
218
+ * @returns A copy of the LocalizedString object for the name.
219
+ */
220
+ getName(): LocalizedString;
221
+ /**
222
+ * Gets the product name for a specific locale, falling back to English ('en').
223
+ * @param locale - The desired locale code.
224
+ * @returns The name string for the specified locale.
225
+ */
226
+ getName(locale: LocaleCode): string;
227
+ /**
228
+ * Gets the full localized product description object.
229
+ * @returns A copy of the LocalizedString object for the description.
230
+ */
231
+ getDescription(): LocalizedString;
232
+ /**
233
+ * Gets the product description for a specific locale, falling back to English ('en').
234
+ * @param locale - The desired locale code.
235
+ * @returns The description string for the specified locale.
236
+ */
237
+ getDescription(locale: LocaleCode): string;
238
+ /**
239
+ * Gets the full localized product slug object.
240
+ * @returns A copy of the LocalizedString object for the slug.
241
+ */
242
+ getSlug(): LocalizedString;
243
+ /**
244
+ * Gets the product slug for a specific locale, falling back to English ('en').
245
+ * @param locale - The desired locale code.
246
+ * @returns The slug string for the specified locale.
247
+ */
248
+ getSlug(locale: LocaleCode): string;
249
+ /**
250
+ * Gets the brand associated with the product.
251
+ * @returns The brand name string.
252
+ */
253
+ getBrand(): string;
254
+ /**
255
+ * Gets the tiered price details for the product.
256
+ * @returns Pricing details mapped by country.
257
+ */
258
+ getPriceDetails(): {
259
+ [country in CountryCode]?: TieredPriceModel;
260
+ };
261
+ /**
262
+ * Gets the tiered price details for a specific country.
263
+ * @param country - The country code.
264
+ * @returns The tiered price model for the country, or null if not found.
265
+ */
266
+ getPriceDetails(country: CountryCode): TieredPriceModel | null;
267
+ /**
268
+ * Gets the variant-specific attributes (color, sizes). Returns copies.
269
+ * @returns Product Attributes.
270
+ */
271
+ getAttributes(): ProductSelectionAttributes;
272
+ /**
273
+ * Gets the variant-specific attributes (color, sizes). Returns copies.
274
+ * @returns Product Attributes.
275
+ */
276
+ getVariants(): VariantModel[];
277
+ /**
278
+ * Gets the images for a specific selection attribute combination.
279
+ * @param selectionAttributes - The selection attributes to search for.
280
+ * @returns The matching image set or null if not found.
281
+ */
282
+ private getImagesBySelectionAttributes;
283
+ /**
284
+ * Gets the images for a specific selection attribute combination.
285
+ * @param selectionAttributes - The selection attributes to search for.
286
+ * @returns The matching image set or null if not found.
287
+ */
288
+ getImages(selectionAttributes: SelectionAttributes): {
289
+ primary: ImageInfoModel;
290
+ gallery: ImageInfoModel[];
291
+ };
292
+ getImages(selectionAttributes: SelectionAttributes, category: ImageCategory.PRIMARY): ImageInfoModel;
293
+ getImages(selectionAttributes: SelectionAttributes, category: ImageCategory.GALLERY): ImageInfoModel[];
294
+ /**
295
+ * Checks if the product is active.
296
+ * @returns True if the product is active, false otherwise.
297
+ */
298
+ getIsActive(): boolean;
299
+ /**
300
+ * Gets the target gender category for the product.
301
+ * @returns The GenderCategory enum value.
302
+ */
303
+ getTargetGender(): GenderCategory;
304
+ /**
305
+ * Gets the list of categories the product belongs to. Returns a copy.
306
+ * @returns An array of category.
307
+ */
308
+ getCategories(): string[];
309
+ /**
310
+ * Gets the product type.
311
+ * @returns ProductType.
312
+ */
313
+ getProductType(): ProductType;
314
+ /**
315
+ * Gets the full localized product specifications object.
316
+ * @returns Product Specifications
317
+ */
318
+ getSpecifications(): LocalizedValue<ProductSpecification>;
319
+ /**
320
+ * Gets the product specifications for a specific locale, falling back to English ('en').
321
+ * @param locale - The desired locale code.
322
+ * @returns The ProductSpecification object for the specified locale, or undefined if not found.
323
+ */
324
+ getSpecifications(locale: LocaleCode): ProductSpecification;
325
+ /**
326
+ * Gets the localized list of search tags. Returns a copy.
327
+ * @returns Localized array of search tags.
328
+ */
329
+ getSearchTags(): LocalizedValue<string[]>;
330
+ /**
331
+ * Gets the search tags for a specific locale, falling back to English ('en').
332
+ * @param locale - The desired locale code.
333
+ * @returns The array of search tags for the specified locale, or undefined if not found.
334
+ */
335
+ getSearchTags(locale: LocaleCode): string[];
336
+ /**
337
+ *
338
+ * @returns ProductData
339
+ */
340
+ getDetails(): ProductData;
341
+ /**
342
+ * Checks if the provided selection attributes are valid for the product.
343
+ * @param selectionAttributes The selection attributes to validate.
344
+ * @throws {SelectionAttributeParseError} If the selection attributes are invalid.
345
+ */
346
+ checkSelectionAttributes(selectionAttributes: SelectionAttributes): void;
347
+ /**
348
+ * Gets the SKU of the variant matching the selection attributes.
349
+ * @param selectionAttributes - The selection attributes to search for.
350
+ * @returns The SKU string, or undefined if no matching variant is found.
351
+ */
352
+ getSku(selectionAttributes: SelectionAttributes): string | undefined;
353
+ /**
354
+ * Validates if the provided selection attributes exist for this product.
355
+ * @param selectionAttributes - The attributes to validate.
356
+ * @returns True if a valid selection attribute exists, false otherwise.
357
+ */
358
+ validateSelectionAttribute(selectionAttributes: SelectionAttributes): boolean;
359
+ /**
360
+ * Validates if a specific size is available for this product.
361
+ * @param size - The size to check.
362
+ * @returns True if the size exists in the product's attributes, false otherwise.
363
+ */
364
+ validateSize(size: string): boolean;
365
+ }
366
+
367
+ export { ProductModel as P, type SelectionAttributes as S, type TieredPriceData as T, VolumeTieredPriceModel as V, TieredPriceModel as a, type ProductSpecification as b, PricingType as c, type PriceTier as d, type PriceTierData as e, type SelectionPricingData as f, type SelectionPricing as g, type PriceTierAttributes as h, type TieredPriceAttributes as i, SelectionTieredPriceModel as j, type ProductSelectionAttributes as k, type VariantData as l, type VariantModel as m, type ProductAttributes as n, type ProductData as o };