@infigo-official/types-for-pricing-script 1.0.4 → 1.0.6

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/package.json CHANGED
@@ -1,15 +1,16 @@
1
1
  {
2
2
  "name": "@infigo-official/types-for-pricing-script",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "Type definitions for Pricing Script Scripting",
5
5
  "types": "v1/index.d.ts",
6
6
  "devDependencies": {
7
+ "http-server": "^14.1.1",
8
+ "typedoc": "^0.24.8",
7
9
  "typescript": "^4.9.5"
8
10
  },
9
11
  "scripts": {
10
- "docs": "cd docusaurus-docs && npm install && npm run build",
11
- "docs:dev": "cd docusaurus-docs && npm start",
12
- "docs:build": "cd docusaurus-docs && npm run build"
12
+ "docs": "npx typedoc",
13
+ "start": "npx http-server docs -p 3000 -o"
13
14
  },
14
15
  "repository": {
15
16
  "type": "git",
@@ -213,9 +213,11 @@ declare interface CheckoutAddress {
213
213
  * The checkout item object available in checkout pricing scripts.
214
214
  * Represents comprehensive checkout information including all items being purchased,
215
215
  * customer details, shipping information, and checkout context.
216
- *
216
+ *
217
217
  * This object provides complete checkout context for pricing calculations that
218
218
  * need to consider shipping, customer information, and multi-item scenarios.
219
+ *
220
+ * @category Global Objects
219
221
  */
220
222
  declare interface CheckoutItem {
221
223
  /**
@@ -12,6 +12,8 @@
12
12
 
13
13
  /**
14
14
  * Interface representing the configuration object.
15
+ *
16
+ * @category Global Objects
15
17
  */
16
18
  interface Configuration {
17
19
  /**
@@ -101,6 +101,8 @@ declare interface CsvHelper {
101
101
  * Helper methods available in pricing scripts for common calculations and data manipulation
102
102
  * These utilities extend the capabilities of pricing scripts and help create more flexible
103
103
  * and maintainable pricing logic.
104
+ *
105
+ * @category Helper Methods
104
106
  */
105
107
  declare interface HelperMethods {
106
108
  /**
@@ -17,9 +17,11 @@
17
17
  * Represents the product variant being priced and provides access to all
18
18
  * product information, attributes, pricing data, and methods for file handling
19
19
  * and attribute management.
20
- *
20
+ *
21
21
  * This object is the primary interface for accessing product data and performing
22
22
  * pricing calculations in pricing scripts.
23
+ *
24
+ * @category Global Objects
23
25
  */
24
26
  declare interface Item {
25
27
  /**
@@ -130,9 +132,13 @@ declare interface Item {
130
132
  /**
131
133
  * The weight of the item in the configured weight unit (typically grams or ounces).
132
134
  * This value is used for shipping calculations and weight-based pricing.
133
- *
135
+ *
134
136
  * @example
135
- * var shippingCost = calculateShippingByWeight(Item.Weight);
137
+ * // Calculate shipping cost based on weight
138
+ * var weightInKg = Item.Weight / 1000;
139
+ * var shippingRate = 2.50; // $2.50 per kg
140
+ * var shippingCost = weightInKg * shippingRate;
141
+ * debug("Item weight: " + Item.Weight + "g, Shipping: $" + shippingCost);
136
142
  */
137
143
  Weight: number;
138
144
 
@@ -140,10 +146,12 @@ declare interface Item {
140
146
  * Indicates whether the weight can be set or modified for this item.
141
147
  * Some products may have fixed weights that cannot be changed,
142
148
  * while others allow weight adjustments based on attributes or custom settings.
143
- *
149
+ *
144
150
  * @example
145
- * if (Item.CanSetWeight) {
146
- * // Allow weight adjustments in the UI
151
+ * if (Item.CanSetWeight && Item.Weight > 5000) {
152
+ * debug("Heavy item detected - weight: " + Item.Weight + "g");
153
+ * // Apply heavy item surcharge
154
+ * return Item.Price + 10.00;
147
155
  * }
148
156
  */
149
157
  CanSetWeight: boolean;
@@ -152,9 +160,13 @@ declare interface Item {
152
160
  * The Stock Keeping Unit (SKU) of the product variant.
153
161
  * This is the unique identifier for the product variant and is used
154
162
  * for inventory management and order processing.
155
- *
163
+ *
156
164
  * @example
157
- * var productIdentifier = Item.Sku;
165
+ * // Apply SKU-specific pricing rules
166
+ * if (Item.Sku.startsWith("PREMIUM-")) {
167
+ * debug("Premium product: " + Item.Sku);
168
+ * return Item.Price * 1.10; // 10% premium markup
169
+ * }
158
170
  */
159
171
  Sku: string;
160
172
 
@@ -162,36 +174,52 @@ declare interface Item {
162
174
  * The actual SKU based on the current attribute combination.
163
175
  * If no attributes are selected, this will be the same as the product SKU.
164
176
  * This value reflects the specific configuration of the product being priced.
165
- *
177
+ *
166
178
  * @example
167
- * var configuredSku = Item.ActualSku;
179
+ * // Log the configured SKU for debugging
180
+ * debug("Base SKU: " + Item.Sku);
181
+ * debug("Configured SKU: " + Item.ActualSku);
182
+ * if (Item.ActualSku !== Item.Sku) {
183
+ * debug("Product has attribute variations");
184
+ * }
168
185
  */
169
186
  ActualSku: string;
170
187
 
171
188
  /**
172
189
  * The width of the item in the configured dimension unit (typically inches or centimeters).
173
190
  * This value is used for packaging calculations and dimensional pricing.
174
- *
191
+ *
175
192
  * @example
176
- * var packagingCost = calculatePackagingCost(Item.Width, Item.Height, Item.Length);
193
+ * // Calculate area-based pricing
194
+ * var area = Item.Width * Item.Height;
195
+ * var pricePerSquareUnit = 0.05;
196
+ * var areaCost = area * pricePerSquareUnit;
197
+ * debug("Area: " + area + " sq units, Cost: $" + areaCost);
177
198
  */
178
199
  Width: number;
179
200
 
180
201
  /**
181
202
  * The height of the item in the configured dimension unit (typically inches or centimeters).
182
203
  * This value is used for packaging calculations and dimensional pricing.
183
- *
204
+ *
184
205
  * @example
185
- * var packagingCost = calculatePackagingCost(Item.Width, Item.Height, Item.Length);
206
+ * // Check if item is oversized
207
+ * if (Item.Height > 48) {
208
+ * debug("Oversized item - adding handling fee");
209
+ * return Item.Price + 25.00;
210
+ * }
186
211
  */
187
212
  Height: number;
188
213
 
189
214
  /**
190
215
  * The length of the item in the configured dimension unit (typically inches or centimeters).
191
216
  * This value is used for packaging calculations and dimensional pricing.
192
- *
217
+ *
193
218
  * @example
194
- * var packagingCost = calculatePackagingCost(Item.Width, Item.Height, Item.Length);
219
+ * // Calculate volume for shipping
220
+ * var volume = Item.Width * Item.Height * Item.Length;
221
+ * var volumetricWeight = volume / 5000; // Standard divisor
222
+ * debug("Volumetric weight: " + volumetricWeight);
195
223
  */
196
224
  Length: number;
197
225
 
@@ -199,9 +227,14 @@ declare interface Item {
199
227
  * The name of the product as displayed to customers.
200
228
  * This is the human-readable product name used in the user interface
201
229
  * and order confirmations.
202
- *
230
+ *
203
231
  * @example
204
- * var displayName = Item.ProductName;
232
+ * debug("Processing order for: " + Item.ProductName);
233
+ * // Check for special product names
234
+ * if (Item.ProductName.indexOf("Rush") >= 0) {
235
+ * debug("Rush order product detected");
236
+ * return Item.Price * 1.50; // 50% rush fee
237
+ * }
205
238
  */
206
239
  ProductName: string;
207
240
 
@@ -265,101 +298,261 @@ declare interface Item {
265
298
 
266
299
  /**
267
300
  * Whether this is a batch job
301
+ *
302
+ * @example
303
+ * if (Item.IsBatch) {
304
+ * debug("Processing batch job with " + Item.NumberOfRecords + " records");
305
+ * var batchSetupFee = 25.00;
306
+ * return Item.Price + batchSetupFee;
307
+ * }
268
308
  */
269
309
  IsBatch: boolean;
270
310
 
271
311
  /**
272
312
  * Number of pages (-1 if not valid)
313
+ *
314
+ * @example
315
+ * if (Item.NumberOfPages > 0) {
316
+ * var perPageCost = 0.10;
317
+ * var pageCost = Item.NumberOfPages * perPageCost;
318
+ * debug("Document has " + Item.NumberOfPages + " pages, adding $" + pageCost);
319
+ * return Item.Price + pageCost;
320
+ * }
273
321
  */
274
322
  NumberOfPages: number;
275
323
 
276
324
  /**
277
325
  * Number of records (-1 if not valid)
326
+ *
327
+ * @example
328
+ * if (Item.NumberOfRecords > 0) {
329
+ * var perRecordCost = 0.05;
330
+ * var recordCost = Item.NumberOfRecords * perRecordCost;
331
+ * debug("Batch has " + Item.NumberOfRecords + " records");
332
+ * return Item.Price + recordCost;
333
+ * }
278
334
  */
279
335
  NumberOfRecords: number;
280
336
 
281
337
  /**
282
338
  * Array of pricing tiers with Price, Quantity, and CustomerRole
339
+ *
340
+ * @example
341
+ * // Find the best tier for the current quantity
342
+ * var tier = HelperMethods.FindTier(Item.Quantity, Item.PricingTiers, Item.CustomerRoles);
343
+ * if (tier) {
344
+ * debug("Using tier: " + tier.Quantity + " @ $" + tier.Price);
345
+ * return tier.Price * Item.Quantity;
346
+ * }
283
347
  */
284
348
  PricingTiers: Tier[];
285
349
 
286
350
  /**
287
351
  * Array of batch tiers (same as PricingTiers but for batch tier table)
352
+ *
353
+ * @example
354
+ * if (Item.IsBatch && Item.BatchTiers.length > 0) {
355
+ * var batchTier = HelperMethods.FindTier(Item.NumberOfRecords, Item.BatchTiers);
356
+ * if (batchTier) {
357
+ * debug("Batch tier price: $" + batchTier.Price);
358
+ * }
359
+ * }
288
360
  */
289
361
  BatchTiers: Tier[];
290
362
 
291
363
  /**
292
364
  * Price per record (-1 if not valid)
365
+ *
366
+ * @example
367
+ * if (Item.PricePerRecord > 0 && Item.NumberOfRecords > 0) {
368
+ * var recordTotal = Item.PricePerRecord * Item.NumberOfRecords;
369
+ * debug("Record pricing: " + Item.NumberOfRecords + " x $" + Item.PricePerRecord);
370
+ * return recordTotal;
371
+ * }
293
372
  */
294
373
  PricePerRecord: number;
295
374
 
296
375
  /**
297
376
  * Array of attributes with Key, Value, IsRequired, Prompt, PriceAdjustment, etc.
377
+ *
378
+ * @example
379
+ * // Loop through all attributes and apply price adjustments
380
+ * var totalAdjustment = 0;
381
+ * for (var i = 0; i < Item.Attributes.length; i++) {
382
+ * var attr = Item.Attributes[i];
383
+ * debug("Attribute: " + attr.Key + " = " + attr.Value);
384
+ * totalAdjustment += attr.PriceAdjustment || 0;
385
+ * }
386
+ * return Item.Price + totalAdjustment;
298
387
  */
299
388
  Attributes: Attribute[];
300
389
 
301
390
  /**
302
391
  * User email
392
+ *
393
+ * @example
394
+ * // Apply corporate discount for company emails
395
+ * if (Item.Email.endsWith("@mycompany.com")) {
396
+ * debug("Corporate customer: " + Item.Email);
397
+ * return Item.Price * 0.85; // 15% corporate discount
398
+ * }
303
399
  */
304
400
  Email: string;
305
401
 
306
402
  /**
307
403
  * Array of customer role system names
404
+ *
405
+ * @example
406
+ * // Check for wholesale pricing
407
+ * if (Item.CustomerRoles.indexOf("Wholesale") >= 0) {
408
+ * debug("Wholesale customer detected");
409
+ * return Item.Price * 0.70; // 30% wholesale discount
410
+ * } else if (Item.CustomerRoles.indexOf("VIP") >= 0) {
411
+ * return Item.Price * 0.90; // 10% VIP discount
412
+ * }
308
413
  */
309
414
  CustomerRoles: string[];
310
415
 
311
416
  /**
312
417
  * Department name of user
418
+ *
419
+ * @example
420
+ * // Apply department-specific pricing
421
+ * if (Item.Department === "Marketing") {
422
+ * debug("Marketing department order");
423
+ * return Item.Price * 0.80; // 20% marketing discount
424
+ * } else if (Item.Department === "Sales") {
425
+ * return Item.Price * 0.75; // 25% sales discount
426
+ * }
313
427
  */
314
428
  Department: string;
315
429
 
316
430
  /**
317
431
  * Array of other order items using the same custom pricing script
432
+ *
433
+ * @example
434
+ * // Calculate total quantity across all cart items for volume discount
435
+ * var totalQty = Item.Quantity;
436
+ * for (var i = 0; i < Item.OtherOrderItems.length; i++) {
437
+ * totalQty += Item.OtherOrderItems[i].Quantity;
438
+ * }
439
+ * debug("Total quantity in cart: " + totalQty);
318
440
  */
319
441
  OtherOrderItems: Item[];
320
442
 
321
443
  /**
322
444
  * Alias of OtherOrderItems
445
+ *
446
+ * @example
447
+ * // Apply cart-wide discount if total exceeds threshold
448
+ * var cartTotal = 0;
449
+ * for (var i = 0; i < Item.CartItems.length; i++) {
450
+ * cartTotal += Item.CartItems[i].Price * Item.CartItems[i].Quantity;
451
+ * }
452
+ * if (cartTotal > 500) {
453
+ * debug("Cart total $" + cartTotal + " - applying 10% discount");
454
+ * return Item.Price * 0.90;
455
+ * }
323
456
  */
324
457
  CartItems: Item[];
325
458
 
326
459
  /**
327
460
  * Index of this item in the other order item array (0 if not in array)
461
+ *
462
+ * @example
463
+ * // Apply setup fee only to first item
464
+ * if (Item.OrderItemIndex === 0) {
465
+ * debug("First item - adding setup fee");
466
+ * return Item.Price + 15.00;
467
+ * }
328
468
  */
329
469
  OrderItemIndex: number;
330
470
 
331
471
  /**
332
472
  * Index of this item in the other order item array (-1 if not in array)
473
+ *
474
+ * @example
475
+ * if (Item.CartItemIndex >= 0) {
476
+ * debug("This is cart item #" + (Item.CartItemIndex + 1));
477
+ * }
333
478
  */
334
479
  CartItemIndex: number;
335
480
 
336
481
  /**
337
482
  * Whether this item is in the other order item array
483
+ *
484
+ * @example
485
+ * if (Item.IsInOtherOrderItems) {
486
+ * debug("Item is part of multi-item order");
487
+ * // Consider other items for bundle pricing
488
+ * }
338
489
  */
339
490
  IsInOtherOrderItems: boolean;
340
491
 
341
492
  /**
342
493
  * Value of the currently used discount code
494
+ *
495
+ * @example
496
+ * // Apply special discount for specific codes
497
+ * if (Item.DiscountCode === "SUMMER20") {
498
+ * debug("Summer sale discount applied");
499
+ * return Item.Price * 0.80; // 20% off
500
+ * } else if (Item.DiscountCode === "VIP50") {
501
+ * return Item.Price * 0.50; // 50% off
502
+ * }
343
503
  */
344
504
  DiscountCode: string;
345
505
 
346
506
  /**
347
507
  * Array of versions with JobId, CustomName, and Quantity
508
+ *
509
+ * @example
510
+ * // Calculate pricing across all versions
511
+ * if (Item.Versions.length > 0) {
512
+ * debug("Job has " + Item.Versions.length + " versions");
513
+ * for (var i = 0; i < Item.Versions.length; i++) {
514
+ * var ver = Item.Versions[i];
515
+ * debug("Version: " + ver.CustomName + ", Qty: " + ver.Quantity);
516
+ * }
517
+ * }
348
518
  */
349
519
  Versions: ItemVersion[];
350
520
 
351
521
  /**
352
522
  * Number of versions
523
+ *
524
+ * @example
525
+ * if (Item.NumberOfVersions > 1) {
526
+ * debug("Multi-version job with " + Item.NumberOfVersions + " versions");
527
+ * // Apply version discount
528
+ * return Item.Price * 0.95; // 5% multi-version discount
529
+ * }
353
530
  */
354
531
  NumberOfVersions: number;
355
532
 
356
533
  /**
357
534
  * Whether this is a version of a job
535
+ *
536
+ * @example
537
+ * if (Item.IsVersion) {
538
+ * debug("This item is a version of an existing job");
539
+ * // Use version-specific pricing logic
540
+ * }
358
541
  */
359
542
  IsVersion: boolean;
360
543
 
361
544
  /**
362
545
  * Sum of all quantities of all versions
546
+ *
547
+ * @example
548
+ * // Use total version quantity for tier pricing
549
+ * if (Item.VersionsSumQuantity > 0) {
550
+ * var tier = HelperMethods.FindTier(Item.VersionsSumQuantity, Item.PricingTiers);
551
+ * if (tier) {
552
+ * debug("Using combined version quantity: " + Item.VersionsSumQuantity);
553
+ * return tier.Price;
554
+ * }
555
+ * }
363
556
  */
364
557
  VersionsSumQuantity: number;
365
558
 
@@ -15,9 +15,10 @@
15
15
  * Output a debug message to the user interface.
16
16
  * Debug messages are typically used during development and troubleshooting
17
17
  * to provide detailed information about script execution and calculations.
18
- *
18
+ *
19
+ * @category Output Functions
19
20
  * @param message - The debug message to display to the user
20
- *
21
+ *
21
22
  * @example
22
23
  * debug("Calculating price for item: " + Item.ProductName);
23
24
  * debug("Base price: $" + Item.Price + ", Quantity: " + Item.Quantity);
@@ -28,9 +29,10 @@ declare function debug(message: string): void;
28
29
  * Output an alert message to the user interface.
29
30
  * Alert messages are used to display important information that requires
30
31
  * user attention, such as pricing changes or special offers.
31
- *
32
+ *
33
+ * @category Output Functions
32
34
  * @param message - The alert message to display to the user
33
- *
35
+ *
34
36
  * @example
35
37
  * alert("Special pricing applied: 20% discount for bulk orders");
36
38
  * alert("Price updated based on selected attributes");
@@ -41,9 +43,10 @@ declare function alert(message: string): void;
41
43
  * Output a warning message to the user interface.
42
44
  * Warning messages are used to notify users about potential issues
43
45
  * or important considerations that may affect their pricing.
44
- *
46
+ *
47
+ * @category Output Functions
45
48
  * @param message - The warning message to display to the user
46
- *
49
+ *
47
50
  * @example
48
51
  * warning("Large file detected - processing may take longer");
49
52
  * warning("Some attributes may affect shipping costs");
@@ -54,9 +57,10 @@ declare function warning(message: string): void;
54
57
  * Output an error message to the user interface.
55
58
  * Error messages are used to inform users about calculation failures
56
59
  * or other issues that prevent normal pricing execution.
57
- *
60
+ *
61
+ * @category Output Functions
58
62
  * @param message - The error message to display to the user
59
- *
63
+ *
60
64
  * @example
61
65
  * error("Unable to calculate price - missing required attributes");
62
66
  * error("File processing failed - please check file format");
@@ -67,9 +71,10 @@ declare function error(message: string): void;
67
71
  * Output a message to the browser console/logs.
68
72
  * Console messages are used for debugging purposes and are typically
69
73
  * only visible to developers in the browser's developer tools.
70
- *
74
+ *
75
+ * @category Output Functions
71
76
  * @param message - The message to log to the console
72
- *
77
+ *
73
78
  * @example
74
79
  * console("Script execution started");
75
80
  * console("Final calculated price: $" + finalPrice);
@@ -13,9 +13,11 @@
13
13
  * The session object available in pricing scripts.
14
14
  * Represents session-level data and provides access to customer information
15
15
  * and shopping cart items that are available during the current session.
16
- *
16
+ *
17
17
  * This object provides session-wide context for pricing calculations that
18
18
  * may need to consider multiple items or customer session data.
19
+ *
20
+ * @category Global Objects
19
21
  */
20
22
  declare interface Session {
21
23
  /**