@infigo-official/types-for-pricing-script 1.0.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.
- package/LICENSE +21 -0
- package/README.md +20 -0
- package/package.json +34 -0
- package/v1/File/FileInfo.d.ts +148 -0
- package/v1/Helper/HelperMethods.d.ts +141 -0
- package/v1/Item/Attribute.d.ts +281 -0
- package/v1/Item/Item.d.ts +362 -0
- package/v1/Item/Tier.d.ts +62 -0
- package/v1/Item/Version.d.ts +130 -0
- package/v1/System/Configuration.d.ts +48 -0
- package/v1/System/Output.d.ts +81 -0
- package/v1/index.d.ts +8 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Infigo
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Types for Pricing Script
|
|
2
|
+
|
|
3
|
+
Type definitions for the Pricing Script scripting interface.
|
|
4
|
+
|
|
5
|
+
Full documentation is available [here](https://infigo-official.github.io/types-for-pricing-script/).
|
|
6
|
+
|
|
7
|
+
Use and install the package to get the best experience and IntelliSense support within our IDE.
|
|
8
|
+
Choose dev dependencies if you are developing in Javascript or our code will not be reused in another project.
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm init
|
|
12
|
+
|
|
13
|
+
# install as dev dependencies
|
|
14
|
+
npm i -D @infigo-official/types-for-pricing-script
|
|
15
|
+
|
|
16
|
+
# ... or ...
|
|
17
|
+
|
|
18
|
+
# install as dependencies
|
|
19
|
+
npm i @infigo-official/types-for-pricing-script
|
|
20
|
+
```
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@infigo-official/types-for-pricing-script",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Type definitions for Pricing Script Scripting",
|
|
5
|
+
"types": "v1/index.d.ts",
|
|
6
|
+
"devDependencies": {
|
|
7
|
+
"typedoc": "^0.26.6",
|
|
8
|
+
"typescript": "^5.5.4"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"docs": "npx typedoc"
|
|
12
|
+
},
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+https://github.com/Infigo-Official/types-for-pricing-script.git"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"typedefinitions",
|
|
19
|
+
"pricingscript",
|
|
20
|
+
"infigo"
|
|
21
|
+
],
|
|
22
|
+
"author": "Infigo",
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"bugs": {
|
|
25
|
+
"url": "https://github.com/Infigo-Official/types-for-pricing-script/issues"
|
|
26
|
+
},
|
|
27
|
+
"homepage": "https://github.com/Infigo-Official/types-for-pricing-script#readme",
|
|
28
|
+
"files": [
|
|
29
|
+
"v1",
|
|
30
|
+
"package.json",
|
|
31
|
+
"README.md",
|
|
32
|
+
"LICENSE"
|
|
33
|
+
]
|
|
34
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This module provides access to file information functionality in pricing scripts.
|
|
3
|
+
* The file handling system provides comprehensive information about uploaded files,
|
|
4
|
+
* allowing scripts to make pricing decisions based on file characteristics including:
|
|
5
|
+
* - File type and MIME type information
|
|
6
|
+
* - File size and dimensional data
|
|
7
|
+
* - Page count for multi-page documents
|
|
8
|
+
* - Content analysis for text-based files
|
|
9
|
+
* - Error handling for file processing
|
|
10
|
+
*
|
|
11
|
+
* @module File
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Page size information for file dimensions.
|
|
16
|
+
* This interface provides dimensional data for individual pages
|
|
17
|
+
* within multi-page documents, useful for calculating costs based
|
|
18
|
+
* on document complexity and size.
|
|
19
|
+
*/
|
|
20
|
+
declare interface PageSize {
|
|
21
|
+
/**
|
|
22
|
+
* The width of the page in points.
|
|
23
|
+
* This value represents the horizontal dimension of the page
|
|
24
|
+
* and is used for calculating printing costs and layout considerations.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* var pageWidth = pageSize.Width;
|
|
28
|
+
* var pageHeight = pageSize.Height;
|
|
29
|
+
* var pageArea = pageWidth * pageHeight;
|
|
30
|
+
*/
|
|
31
|
+
Width: number;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The height of the page in points.
|
|
35
|
+
* This value represents the vertical dimension of the page
|
|
36
|
+
* and is used for calculating printing costs and layout considerations.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* var pageWidth = pageSize.Width;
|
|
40
|
+
* var pageHeight = pageSize.Height;
|
|
41
|
+
* var pageArea = pageWidth * pageHeight;
|
|
42
|
+
*/
|
|
43
|
+
Height: number;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Comprehensive file information object returned by getFileInfo methods.
|
|
48
|
+
* This interface provides detailed information about uploaded files,
|
|
49
|
+
* allowing pricing scripts to make decisions based on file characteristics
|
|
50
|
+
* such as size, type, dimensions, and content.
|
|
51
|
+
*
|
|
52
|
+
* File information is essential for file-based pricing models where
|
|
53
|
+
* costs are calculated based on file properties rather than just
|
|
54
|
+
* product specifications.
|
|
55
|
+
*/
|
|
56
|
+
declare interface FileInfo {
|
|
57
|
+
/**
|
|
58
|
+
* The MIME type of the file.
|
|
59
|
+
* This value indicates the file format and type, allowing scripts
|
|
60
|
+
* to apply different pricing logic based on file type.
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* if (fileInfo.MimeType === "application/pdf") {
|
|
64
|
+
* return Item.Price + (fileInfo.NumberOfPages * 0.50); // $0.50 per page
|
|
65
|
+
* } else if (fileInfo.MimeType.startsWith("image/")) {
|
|
66
|
+
* return Item.Price + 2.00; // $2.00 for image files
|
|
67
|
+
* }
|
|
68
|
+
*/
|
|
69
|
+
MimeType: string;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* The size of the file in bytes.
|
|
73
|
+
* This value is used for size-based pricing models and to determine
|
|
74
|
+
* processing costs based on file complexity.
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* if (fileInfo.Size > 1024 * 1024) { // > 1MB
|
|
78
|
+
* return Item.Price * 1.2; // 20% markup for large files
|
|
79
|
+
* }
|
|
80
|
+
*/
|
|
81
|
+
Size: number;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* The number of pages in the document.
|
|
85
|
+
* This value is only set for PDF attachments that can be parsed correctly
|
|
86
|
+
* and when the file size is within the 10 MB limitation.
|
|
87
|
+
* Used for page-based pricing models.
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* if (fileInfo.NumberOfPages > 0) {
|
|
91
|
+
* return Item.Price + (fileInfo.NumberOfPages * 0.25); // $0.25 per page
|
|
92
|
+
* }
|
|
93
|
+
*/
|
|
94
|
+
NumberOfPages: number;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Array of page size items, each having Width and Height properties.
|
|
98
|
+
* This array provides dimensional information for each page in the document,
|
|
99
|
+
* allowing for precise cost calculations based on page dimensions.
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* var totalArea = 0;
|
|
103
|
+
* for (var i = 0; i < fileInfo.Dimensions.length; i++) {
|
|
104
|
+
* var page = fileInfo.Dimensions[i];
|
|
105
|
+
* totalArea += page.Width * page.Height;
|
|
106
|
+
* }
|
|
107
|
+
* return Item.Price + (totalArea * 0.0001); // Cost based on total area
|
|
108
|
+
*/
|
|
109
|
+
Dimensions: PageSize[];
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* The number of lines in a text/csv file.
|
|
113
|
+
* This value is only set when the readContent flag is set during
|
|
114
|
+
* file information retrieval. Used for line-based pricing models.
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* if (fileInfo.NumberOfRecords > 0) {
|
|
118
|
+
* return Item.Price + (fileInfo.NumberOfRecords * 0.01); // $0.01 per line
|
|
119
|
+
* }
|
|
120
|
+
*/
|
|
121
|
+
NumberOfRecords: number;
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Array of lines with the text file content.
|
|
125
|
+
* This array is only set when the readContent flag is set and the file
|
|
126
|
+
* size is smaller than the 50KB limitation. Used for content-based pricing.
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* if (fileInfo.Content && fileInfo.Content.length > 0) {
|
|
130
|
+
* var lineCount = fileInfo.Content.length;
|
|
131
|
+
* return Item.Price + (lineCount * 0.005); // $0.005 per line
|
|
132
|
+
* }
|
|
133
|
+
*/
|
|
134
|
+
Content: string[];
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Error message indicating any issues encountered during file processing.
|
|
138
|
+
* This value is empty if retrieving file information was successful.
|
|
139
|
+
* Used for error handling and debugging file processing issues.
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* if (fileInfo.Error) {
|
|
143
|
+
* error("File processing error: " + fileInfo.Error);
|
|
144
|
+
* return Item.Price; // Fallback to base price
|
|
145
|
+
* }
|
|
146
|
+
*/
|
|
147
|
+
Error: string;
|
|
148
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CSV parsing options
|
|
3
|
+
*/
|
|
4
|
+
declare interface CsvOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Delimiter character (default: ",")
|
|
7
|
+
*/
|
|
8
|
+
delimiterChar?: string;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Quote character (default: '"')
|
|
12
|
+
*/
|
|
13
|
+
quoteChar?: string;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Whether to disable number conversion (default: false)
|
|
17
|
+
*/
|
|
18
|
+
disableNumberConverstion?: boolean;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* CSV replacer function for stringify
|
|
23
|
+
*/
|
|
24
|
+
declare type CsvReplacer = (row: number, col: number, value: any) => any;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* CSV stringify options
|
|
28
|
+
*/
|
|
29
|
+
declare interface CsvStringifyOptions {
|
|
30
|
+
/**
|
|
31
|
+
* Delimiter character (default: ",")
|
|
32
|
+
*/
|
|
33
|
+
delimiterChar?: string;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Quote character (default: '"')
|
|
37
|
+
*/
|
|
38
|
+
quoteChar?: string;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Replacer function for custom value transformation
|
|
42
|
+
*/
|
|
43
|
+
replacer?: CsvReplacer;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* CSV helper methods
|
|
48
|
+
*/
|
|
49
|
+
declare interface CsvHelper {
|
|
50
|
+
/**
|
|
51
|
+
* Parse CSV string into array of arrays
|
|
52
|
+
* @param csv - CSV string to parse
|
|
53
|
+
* @param options - Parsing options
|
|
54
|
+
* @param disableNumberConversion - Whether to disable number conversion
|
|
55
|
+
* @returns Array of arrays representing the CSV data
|
|
56
|
+
*/
|
|
57
|
+
parse(csv: string, options?: CsvOptions, disableNumberConversion?: boolean): any[][];
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Convert array of arrays to CSV string
|
|
61
|
+
* @param table - Array of arrays to convert
|
|
62
|
+
* @param options - Stringify options
|
|
63
|
+
* @returns CSV string
|
|
64
|
+
*/
|
|
65
|
+
stringify(table: any[][], options?: CsvStringifyOptions): string;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Helper methods available in pricing scripts
|
|
70
|
+
*/
|
|
71
|
+
declare interface HelperMethods {
|
|
72
|
+
/**
|
|
73
|
+
* Find the appropriate tier based on quantity and customer roles
|
|
74
|
+
* @param quantity - The quantity to find tier for
|
|
75
|
+
* @param tiers - Array of tier objects
|
|
76
|
+
* @param roles - Array of customer role system names
|
|
77
|
+
* @returns Tier object or null if no tier found
|
|
78
|
+
*/
|
|
79
|
+
FindTier(quantity: number, tiers: Tier[], roles?: string[]): Tier | null;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Get attribute price adjustments including tier price adjustments
|
|
83
|
+
* @param quantity - The quantity to get adjustments for
|
|
84
|
+
* @param roles - Array of customer role system names
|
|
85
|
+
* @returns Total price adjustment
|
|
86
|
+
*/
|
|
87
|
+
GetAttributePriceAdjustment(quantity: number, roles?: string[]): number;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Interpolate price based on quantity and tiers
|
|
91
|
+
* @param quantity - The quantity to interpolate price for
|
|
92
|
+
* @param tiers - Array of tier objects
|
|
93
|
+
* @returns Interpolated price
|
|
94
|
+
*/
|
|
95
|
+
InterpolatePrice(quantity: number, tiers: Tier[]): number;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Log all properties of an object to console
|
|
99
|
+
* @param data - Object to log
|
|
100
|
+
*/
|
|
101
|
+
LogObject(data: any): void;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Check if an array contains a specific value
|
|
105
|
+
* @param array - Array to check
|
|
106
|
+
* @param value - Value to search for
|
|
107
|
+
* @returns Whether the value is found
|
|
108
|
+
*/
|
|
109
|
+
Contains(array: any[], value: any): boolean;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Check if an item is an object
|
|
113
|
+
* @param item - Item to check
|
|
114
|
+
* @returns Whether the item is an object
|
|
115
|
+
*/
|
|
116
|
+
IsObject(item: any): boolean;
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Check if an item is an array
|
|
120
|
+
* @param item - Item to check
|
|
121
|
+
* @returns Whether the item is an array
|
|
122
|
+
*/
|
|
123
|
+
IsArray(item: any): boolean;
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Merge source object into target object
|
|
127
|
+
* @param target - Target object to merge into
|
|
128
|
+
* @param source - Source object to merge from
|
|
129
|
+
*/
|
|
130
|
+
MergeObject(target: any, source: any): void;
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* CSV parsing and stringifying utilities
|
|
134
|
+
*/
|
|
135
|
+
CSV: CsvHelper;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Global HelperMethods object
|
|
140
|
+
*/
|
|
141
|
+
declare const HelperMethods: HelperMethods;
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This module provides access to attribute management functionality in pricing scripts.
|
|
3
|
+
* Attributes represent configurable options for products that can affect pricing, weight, and dimensions.
|
|
4
|
+
* The attribute system provides a flexible way to handle complex product configurations including:
|
|
5
|
+
* - Product options and variants
|
|
6
|
+
* - Price adjustments based on selections
|
|
7
|
+
* - Weight and dimensional modifications
|
|
8
|
+
* - Tier-based pricing adjustments
|
|
9
|
+
* - Required vs optional attributes
|
|
10
|
+
*
|
|
11
|
+
* @module Item / Attribute
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Represents an individual value within an attribute.
|
|
16
|
+
* Attribute values define the specific options available for a product attribute,
|
|
17
|
+
* including their pricing implications and physical adjustments.
|
|
18
|
+
*
|
|
19
|
+
* Each attribute value can have its own price, weight, and dimensional adjustments,
|
|
20
|
+
* allowing for precise control over how product options affect the final pricing.
|
|
21
|
+
*/
|
|
22
|
+
declare interface AttributeValue {
|
|
23
|
+
/**
|
|
24
|
+
* The display value of the attribute option as shown to customers.
|
|
25
|
+
* This is the human-readable text that appears in the user interface
|
|
26
|
+
* for this specific attribute option.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* var selectedColor = attr.Value; // "Red", "Blue", "Green", etc.
|
|
30
|
+
*/
|
|
31
|
+
Value: string;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The unique identifier for this attribute value.
|
|
35
|
+
* This ID is used internally for tracking and processing attribute selections
|
|
36
|
+
* and should not be displayed to end users.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* var valueId = attr.Id; // "color_red_001", "size_large_002", etc.
|
|
40
|
+
*/
|
|
41
|
+
Id: string;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* The price adjustment amount for this attribute value.
|
|
45
|
+
* This value is added to or subtracted from the base product price
|
|
46
|
+
* when this attribute value is selected.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* var finalPrice = Item.Price + attr.PriceAdjustment;
|
|
50
|
+
*/
|
|
51
|
+
PriceAdjustment: number;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* The weight adjustment amount for this attribute value.
|
|
55
|
+
* This value is added to or subtracted from the base product weight
|
|
56
|
+
* when this attribute value is selected, affecting shipping calculations.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* var adjustedWeight = Item.Weight + attr.WeightAdjustment;
|
|
60
|
+
*/
|
|
61
|
+
WeightAdjustment: number;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* The length adjustment amount for this attribute value.
|
|
65
|
+
* This value modifies the product's length dimension when this
|
|
66
|
+
* attribute value is selected, affecting packaging calculations.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* var adjustedLength = Item.Length + attr.LengthAdjustment;
|
|
70
|
+
*/
|
|
71
|
+
LengthAdjustment: number;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* The width adjustment amount for this attribute value.
|
|
75
|
+
* This value modifies the product's width dimension when this
|
|
76
|
+
* attribute value is selected, affecting packaging calculations.
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* var adjustedWidth = Item.Width + attr.WidthAdjustment;
|
|
80
|
+
*/
|
|
81
|
+
WidthAdjustment: number;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* The height adjustment amount for this attribute value.
|
|
85
|
+
* This value modifies the product's height dimension when this
|
|
86
|
+
* attribute value is selected, affecting packaging calculations.
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* var adjustedHeight = Item.Height + attr.HeightAdjustment;
|
|
90
|
+
*/
|
|
91
|
+
HeightAdjustment: number;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Indicates whether the price adjustment should be applied as a percentage
|
|
95
|
+
* rather than a fixed amount. When true, the PriceAdjustment value is
|
|
96
|
+
* treated as a percentage of the base price.
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* if (attr.PriceAdjustmentIsPercentage) {
|
|
100
|
+
* var adjustment = Item.Price * (attr.PriceAdjustment / 100);
|
|
101
|
+
* } else {
|
|
102
|
+
* var adjustment = attr.PriceAdjustment;
|
|
103
|
+
* }
|
|
104
|
+
*/
|
|
105
|
+
PriceAdjustmentIsPercentage: boolean;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Indicates whether tier-based price adjustments should be used for this attribute value.
|
|
109
|
+
* When true, the system will use the TierPriceAdjustments array instead of
|
|
110
|
+
* the standard PriceAdjustment for quantity-based pricing.
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* if (attr.UseTierPriceAdjustment) {
|
|
114
|
+
* var tierAdjustment = HelperMethods.FindTier(Item.Quantity, attr.TierPriceAdjustments);
|
|
115
|
+
* }
|
|
116
|
+
*/
|
|
117
|
+
UseTierPriceAdjustment: boolean;
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Array of tier-based price adjustments for this attribute value.
|
|
121
|
+
* Each tier defines a quantity threshold and corresponding price adjustment,
|
|
122
|
+
* allowing for quantity-based pricing variations for this specific attribute option.
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* var tierAdjustment = HelperMethods.FindTier(Item.Quantity, attr.TierPriceAdjustments);
|
|
126
|
+
* if (tierAdjustment) {
|
|
127
|
+
* var finalPrice = Item.Price + tierAdjustment.Price;
|
|
128
|
+
* }
|
|
129
|
+
*/
|
|
130
|
+
TierPriceAdjustments: Tier[];
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Represents a product attribute with its configuration and available values.
|
|
135
|
+
* Attributes define the configurable options for a product, such as color, size,
|
|
136
|
+
* material, or any other product variant that affects pricing or specifications.
|
|
137
|
+
*
|
|
138
|
+
* Each attribute contains a collection of possible values and defines how
|
|
139
|
+
* those values affect the product's pricing, weight, and dimensions.
|
|
140
|
+
*/
|
|
141
|
+
declare interface Attribute {
|
|
142
|
+
/**
|
|
143
|
+
* The unique key or name identifier for this attribute.
|
|
144
|
+
* This is used internally to identify the attribute and should be
|
|
145
|
+
* consistent across different product configurations.
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
* var attrKey = attr.Key; // "color", "size", "material", etc.
|
|
149
|
+
*/
|
|
150
|
+
Key: string;
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* The display text shown to customers when selecting this attribute.
|
|
154
|
+
* This is the human-readable label that appears in the user interface
|
|
155
|
+
* to describe what this attribute represents.
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* var prompt = attr.Prompt; // "Select Color", "Choose Size", etc.
|
|
159
|
+
*/
|
|
160
|
+
Prompt: string;
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Indicates whether this attribute must be selected before the product
|
|
164
|
+
* can be added to the cart. Required attributes typically represent
|
|
165
|
+
* essential product specifications.
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* if (attr.IsRequired && !attr.Value) {
|
|
169
|
+
* error("Please select a " + attr.Prompt);
|
|
170
|
+
* }
|
|
171
|
+
*/
|
|
172
|
+
IsRequired: boolean;
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* The currently selected value for this attribute.
|
|
176
|
+
* This represents the customer's choice for this attribute option.
|
|
177
|
+
* Empty string indicates no selection has been made.
|
|
178
|
+
*
|
|
179
|
+
* @example
|
|
180
|
+
* var selectedValue = attr.Value; // "Red", "Large", "Premium", etc.
|
|
181
|
+
*/
|
|
182
|
+
Value: string;
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* The price adjustment amount for the currently selected attribute value.
|
|
186
|
+
* This value is calculated based on the selected AttributeValue and
|
|
187
|
+
* represents the total price impact of this attribute selection.
|
|
188
|
+
*
|
|
189
|
+
* @example
|
|
190
|
+
* var totalPrice = Item.Price + attr.PriceAdjustment;
|
|
191
|
+
*/
|
|
192
|
+
PriceAdjustment: number;
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* The weight adjustment amount for the currently selected attribute value.
|
|
196
|
+
* This value represents the total weight impact of this attribute selection,
|
|
197
|
+
* affecting shipping and handling calculations.
|
|
198
|
+
*
|
|
199
|
+
* @example
|
|
200
|
+
* var totalWeight = Item.Weight + attr.WeightAdjustment;
|
|
201
|
+
*/
|
|
202
|
+
WeightAdjustment: number;
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Indicates whether the price adjustment should be applied as a percentage
|
|
206
|
+
* rather than a fixed amount. When true, the PriceAdjustment value is
|
|
207
|
+
* treated as a percentage of the base price.
|
|
208
|
+
*
|
|
209
|
+
* @example
|
|
210
|
+
* if (attr.PriceAdjustmentIsPercentage) {
|
|
211
|
+
* var adjustment = Item.Price * (attr.PriceAdjustment / 100);
|
|
212
|
+
* } else {
|
|
213
|
+
* var adjustment = attr.PriceAdjustment;
|
|
214
|
+
* }
|
|
215
|
+
*/
|
|
216
|
+
PriceAdjustmentIsPercentage: boolean;
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* The type or category of this attribute.
|
|
220
|
+
* This defines the kind of attribute (e.g., "color", "size", "material")
|
|
221
|
+
* and may affect how the attribute is displayed or processed.
|
|
222
|
+
*
|
|
223
|
+
* @example
|
|
224
|
+
* if (attr.Type === "color") {
|
|
225
|
+
* // Handle color-specific logic
|
|
226
|
+
* }
|
|
227
|
+
*/
|
|
228
|
+
Type: string;
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* The unique numeric identifier for this attribute.
|
|
232
|
+
* This ID is used internally for database operations and system processing.
|
|
233
|
+
*
|
|
234
|
+
* @example
|
|
235
|
+
* var attrId = attr.Id; // 1, 2, 3, etc.
|
|
236
|
+
*/
|
|
237
|
+
Id: number;
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Array of all possible values available for this attribute.
|
|
241
|
+
* Each value represents a selectable option with its own pricing
|
|
242
|
+
* and adjustment implications.
|
|
243
|
+
*
|
|
244
|
+
* @example
|
|
245
|
+
* for (var i = 0; i < attr.Values.length; i++) {
|
|
246
|
+
* var option = attr.Values[i];
|
|
247
|
+
* console.log(option.Value + ": $" + option.PriceAdjustment);
|
|
248
|
+
* }
|
|
249
|
+
*/
|
|
250
|
+
Values: AttributeValue[];
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* The length adjustment amount for the currently selected attribute value.
|
|
254
|
+
* This value represents the total length impact of this attribute selection,
|
|
255
|
+
* affecting packaging and dimensional calculations.
|
|
256
|
+
*
|
|
257
|
+
* @example
|
|
258
|
+
* var totalLength = Item.Length + attr.LengthAdjustment;
|
|
259
|
+
*/
|
|
260
|
+
LengthAdjustment: number;
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* The width adjustment amount for the currently selected attribute value.
|
|
264
|
+
* This value represents the total width impact of this attribute selection,
|
|
265
|
+
* affecting packaging and dimensional calculations.
|
|
266
|
+
*
|
|
267
|
+
* @example
|
|
268
|
+
* var totalWidth = Item.Width + attr.WidthAdjustment;
|
|
269
|
+
*/
|
|
270
|
+
WidthAdjustment: number;
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* The height adjustment amount for the currently selected attribute value.
|
|
274
|
+
* This value represents the total height impact of this attribute selection,
|
|
275
|
+
* affecting packaging and dimensional calculations.
|
|
276
|
+
*
|
|
277
|
+
* @example
|
|
278
|
+
* var totalHeight = Item.Height + attr.HeightAdjustment;
|
|
279
|
+
*/
|
|
280
|
+
HeightAdjustment: number;
|
|
281
|
+
}
|
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This module provides access to the main item object in pricing scripts.
|
|
3
|
+
* The Item interface represents the product variant being priced and contains all
|
|
4
|
+
* the essential information needed for pricing calculations including:
|
|
5
|
+
* - Product pricing information (base price, special prices, costs)
|
|
6
|
+
* - Product details (SKU, name, categories, dimensions)
|
|
7
|
+
* - Quantity and packaging information
|
|
8
|
+
* - Attribute management and pricing adjustments
|
|
9
|
+
* - File handling capabilities
|
|
10
|
+
* - Tier-based pricing support
|
|
11
|
+
*
|
|
12
|
+
* @module Item
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The main item object available in pricing scripts.
|
|
17
|
+
* Represents the product variant being priced and provides access to all
|
|
18
|
+
* product information, attributes, pricing data, and methods for file handling
|
|
19
|
+
* and attribute management.
|
|
20
|
+
*
|
|
21
|
+
* This object is the primary interface for accessing product data and performing
|
|
22
|
+
* pricing calculations in pricing scripts.
|
|
23
|
+
*/
|
|
24
|
+
declare interface Item {
|
|
25
|
+
/**
|
|
26
|
+
* The standard product variant price in the base currency.
|
|
27
|
+
* This is the base price before any attribute adjustments, tier pricing,
|
|
28
|
+
* or special pricing is applied.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* var basePrice = Item.Price;
|
|
32
|
+
* var adjustedPrice = basePrice * 1.2; // 20% markup
|
|
33
|
+
*/
|
|
34
|
+
Price: number;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* The old price from the product variant, typically used for displaying
|
|
38
|
+
* price comparisons or discounts. This value represents the previous
|
|
39
|
+
* price before any recent price changes.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* if (Item.OldPrice > Item.Price) {
|
|
43
|
+
* var discount = Item.OldPrice - Item.Price;
|
|
44
|
+
* return "Save $" + discount.toFixed(2);
|
|
45
|
+
* }
|
|
46
|
+
*/
|
|
47
|
+
OldPrice: number;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* The product cost, representing the actual cost to produce or acquire
|
|
51
|
+
* the product. This value is used for margin calculations and profit analysis.
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* var margin = Item.Price - Item.ProductCost;
|
|
55
|
+
* var marginPercentage = (margin / Item.Price) * 100;
|
|
56
|
+
*/
|
|
57
|
+
ProductCost: number;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* The special price for the product variant, if applicable.
|
|
61
|
+
* This value is null if no special pricing is currently active.
|
|
62
|
+
* Special pricing typically overrides the standard price for promotional periods.
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* var finalPrice = Item.SpecialPrice || Item.Price;
|
|
66
|
+
*/
|
|
67
|
+
SpecialPrice: number | null;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* The start date for special pricing, if applicable.
|
|
71
|
+
* This value is null if no special pricing is currently active.
|
|
72
|
+
* Used to determine if special pricing should be applied based on current date.
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* var now = new Date();
|
|
76
|
+
* if (Item.SpecialPriceStartDate && now >= Item.SpecialPriceStartDate) {
|
|
77
|
+
* return Item.SpecialPrice;
|
|
78
|
+
* }
|
|
79
|
+
*/
|
|
80
|
+
SpecialPriceStartDate: Date | null;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* The end date for special pricing, if applicable.
|
|
84
|
+
* This value is null if no special pricing is currently active.
|
|
85
|
+
* Used to determine if special pricing should be applied based on current date.
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* var now = new Date();
|
|
89
|
+
* if (Item.SpecialPriceEndDate && now <= Item.SpecialPriceEndDate) {
|
|
90
|
+
* return Item.SpecialPrice;
|
|
91
|
+
* }
|
|
92
|
+
*/
|
|
93
|
+
SpecialPriceEndDate: Date | null;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Additional shipping charge for this specific product variant.
|
|
97
|
+
* This value is added to the base shipping cost and represents
|
|
98
|
+
* any extra shipping fees specific to this item.
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* var totalShipping = baseShippingCost + Item.AdditionalShippingCharge;
|
|
102
|
+
*/
|
|
103
|
+
AdditionalShippingCharge: number;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* The weight of the item in the configured weight unit (typically grams or ounces).
|
|
107
|
+
* This value is used for shipping calculations and weight-based pricing.
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* var shippingCost = calculateShippingByWeight(Item.Weight);
|
|
111
|
+
*/
|
|
112
|
+
Weight: number;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Indicates whether the weight can be set or modified for this item.
|
|
116
|
+
* Some products may have fixed weights that cannot be changed,
|
|
117
|
+
* while others allow weight adjustments based on attributes or custom settings.
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* if (Item.CanSetWeight) {
|
|
121
|
+
* // Allow weight adjustments in the UI
|
|
122
|
+
* }
|
|
123
|
+
*/
|
|
124
|
+
CanSetWeight: boolean;
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* The Stock Keeping Unit (SKU) of the product variant.
|
|
128
|
+
* This is the unique identifier for the product variant and is used
|
|
129
|
+
* for inventory management and order processing.
|
|
130
|
+
*
|
|
131
|
+
* @example
|
|
132
|
+
* var productIdentifier = Item.Sku;
|
|
133
|
+
*/
|
|
134
|
+
Sku: string;
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* The actual SKU based on the current attribute combination.
|
|
138
|
+
* If no attributes are selected, this will be the same as the product SKU.
|
|
139
|
+
* This value reflects the specific configuration of the product being priced.
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* var configuredSku = Item.ActualSku;
|
|
143
|
+
*/
|
|
144
|
+
ActualSku: string;
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* The width of the item in the configured dimension unit (typically inches or centimeters).
|
|
148
|
+
* This value is used for packaging calculations and dimensional pricing.
|
|
149
|
+
*
|
|
150
|
+
* @example
|
|
151
|
+
* var packagingCost = calculatePackagingCost(Item.Width, Item.Height, Item.Length);
|
|
152
|
+
*/
|
|
153
|
+
Width: number;
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* The height of the item in the configured dimension unit (typically inches or centimeters).
|
|
157
|
+
* This value is used for packaging calculations and dimensional pricing.
|
|
158
|
+
*
|
|
159
|
+
* @example
|
|
160
|
+
* var packagingCost = calculatePackagingCost(Item.Width, Item.Height, Item.Length);
|
|
161
|
+
*/
|
|
162
|
+
Height: number;
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* The length of the item in the configured dimension unit (typically inches or centimeters).
|
|
166
|
+
* This value is used for packaging calculations and dimensional pricing.
|
|
167
|
+
*
|
|
168
|
+
* @example
|
|
169
|
+
* var packagingCost = calculatePackagingCost(Item.Width, Item.Height, Item.Length);
|
|
170
|
+
*/
|
|
171
|
+
Length: number;
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* The name of the product as displayed to customers.
|
|
175
|
+
* This is the human-readable product name used in the user interface
|
|
176
|
+
* and order confirmations.
|
|
177
|
+
*
|
|
178
|
+
* @example
|
|
179
|
+
* var displayName = Item.ProductName;
|
|
180
|
+
*/
|
|
181
|
+
ProductName: string;
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Array of category names that this product belongs to.
|
|
185
|
+
* Categories are used for product organization, filtering, and
|
|
186
|
+
* category-specific pricing rules.
|
|
187
|
+
*
|
|
188
|
+
* @example
|
|
189
|
+
* if (Item.Categories.includes("Premium")) {
|
|
190
|
+
* return Item.Price * 1.1; // 10% premium markup
|
|
191
|
+
* }
|
|
192
|
+
*/
|
|
193
|
+
Categories: string[];
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* The order quantity for this item.
|
|
197
|
+
* This represents how many units of this product variant are being ordered.
|
|
198
|
+
* Used for quantity-based pricing and tier calculations.
|
|
199
|
+
*
|
|
200
|
+
* @example
|
|
201
|
+
* var tier = HelperMethods.FindTier(Item.Quantity, Item.PricingTiers);
|
|
202
|
+
*/
|
|
203
|
+
Quantity: number;
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* The pack quantity, calculated as the order quantity divided by the product variant's
|
|
207
|
+
* OrderPackQuantity. This represents how many packs are being ordered.
|
|
208
|
+
*
|
|
209
|
+
* @example
|
|
210
|
+
* var packPrice = Item.Price * Item.PackQuantity;
|
|
211
|
+
*/
|
|
212
|
+
PackQuantity: number;
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* The quantity selector mode for this product.
|
|
216
|
+
* This determines how quantity selection is handled in the user interface
|
|
217
|
+
* and affects pricing calculations.
|
|
218
|
+
*
|
|
219
|
+
* @example
|
|
220
|
+
* switch (Item.QuantitySelectorMode) {
|
|
221
|
+
* case 1: // Individual units
|
|
222
|
+
* return Item.Price * Item.Quantity;
|
|
223
|
+
* case 2: // Packs
|
|
224
|
+
* return Item.Price * Item.PackQuantity;
|
|
225
|
+
* }
|
|
226
|
+
*/
|
|
227
|
+
QuantitySelectorMode: number;
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Whether this is a batch job
|
|
231
|
+
*/
|
|
232
|
+
IsBatch: boolean;
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Number of pages (-1 if not valid)
|
|
236
|
+
*/
|
|
237
|
+
NumberOfPages: number;
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Number of records (-1 if not valid)
|
|
241
|
+
*/
|
|
242
|
+
NumberOfRecords: number;
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Array of pricing tiers with Price, Quantity, and CustomerRole
|
|
246
|
+
*/
|
|
247
|
+
PricingTiers: Tier[];
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Array of batch tiers (same as PricingTiers but for batch tier table)
|
|
251
|
+
*/
|
|
252
|
+
BatchTiers: Tier[];
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Price per record (-1 if not valid)
|
|
256
|
+
*/
|
|
257
|
+
PricePerRecord: number;
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Array of attributes with Key, Value, IsRequired, Prompt, PriceAdjustment, etc.
|
|
261
|
+
*/
|
|
262
|
+
Attributes: Attribute[];
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* User email
|
|
266
|
+
*/
|
|
267
|
+
Email: string;
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* Array of customer role system names
|
|
271
|
+
*/
|
|
272
|
+
CustomerRoles: string[];
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Department name of user
|
|
276
|
+
*/
|
|
277
|
+
Department: string;
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Array of other order items using the same custom pricing script
|
|
281
|
+
*/
|
|
282
|
+
OtherOrderItems: Item[];
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Alias of OtherOrderItems
|
|
286
|
+
*/
|
|
287
|
+
CartItems: Item[];
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Index of this item in the other order item array (0 if not in array)
|
|
291
|
+
*/
|
|
292
|
+
OrderItemIndex: number;
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Index of this item in the other order item array (-1 if not in array)
|
|
296
|
+
*/
|
|
297
|
+
CartItemIndex: number;
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Whether this item is in the other order item array
|
|
301
|
+
*/
|
|
302
|
+
IsInOtherOrderItems: boolean;
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* Value of the currently used discount code
|
|
306
|
+
*/
|
|
307
|
+
DiscountCode: string;
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* Array of versions with JobId, CustomName, and Quantity
|
|
311
|
+
*/
|
|
312
|
+
Versions: ItemVersion[];
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* Number of versions
|
|
316
|
+
*/
|
|
317
|
+
NumberOfVersions: number;
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* Whether this is a version of a job
|
|
321
|
+
*/
|
|
322
|
+
IsVersion: boolean;
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* Sum of all quantities of all versions
|
|
326
|
+
*/
|
|
327
|
+
VersionsSumQuantity: number;
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* Get file information for attached files
|
|
331
|
+
* @param attributeId - ID of the attribute
|
|
332
|
+
* @param readContent - Whether to read file content
|
|
333
|
+
* @returns FileInfo object
|
|
334
|
+
*/
|
|
335
|
+
getFileInfo(attributeId: string, readContent: boolean): FileInfo;
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* Shortcut method to retrieve an attribute value by name
|
|
339
|
+
* @param attribute - Name of the attribute
|
|
340
|
+
* @returns Attribute value
|
|
341
|
+
*/
|
|
342
|
+
getAttributeValue(attribute: string): string;
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* Set the attribute value permanently to the given value
|
|
346
|
+
* @param attribute - Name of the attribute
|
|
347
|
+
* @param value - Value to set
|
|
348
|
+
*/
|
|
349
|
+
setAttributeValue(attribute: string, value: string): void;
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* Get file information for a specific configurable file from Global Data
|
|
353
|
+
* @param filename - Name of the file
|
|
354
|
+
* @returns FileInfo object
|
|
355
|
+
*/
|
|
356
|
+
getGlobalFileContent(filename: string): FileInfo;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* Global Item object
|
|
361
|
+
*/
|
|
362
|
+
declare const Item: Item;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This module provides access to tier-based pricing functionality in pricing scripts.
|
|
3
|
+
* The tier system supports sophisticated quantity-based pricing models that can
|
|
4
|
+
* account for quantity discounts and customer-specific pricing including:
|
|
5
|
+
* - Quantity-based pricing tiers
|
|
6
|
+
* - Customer role-specific pricing
|
|
7
|
+
* - Volume discount calculations
|
|
8
|
+
* - Tier boundary management
|
|
9
|
+
*
|
|
10
|
+
* @module Item / Tier
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Represents a pricing tier for quantity-based pricing.
|
|
15
|
+
* Pricing tiers define quantity thresholds and corresponding prices,
|
|
16
|
+
* allowing for volume discounts and quantity-based pricing variations.
|
|
17
|
+
*
|
|
18
|
+
* Each tier specifies a minimum quantity threshold and the price that
|
|
19
|
+
* applies when the order quantity meets or exceeds that threshold.
|
|
20
|
+
* Tiers can also be restricted to specific customer roles for
|
|
21
|
+
* role-based pricing strategies.
|
|
22
|
+
*/
|
|
23
|
+
declare interface Tier {
|
|
24
|
+
/**
|
|
25
|
+
* The quantity threshold for this tier.
|
|
26
|
+
* This value represents the minimum quantity required to qualify
|
|
27
|
+
* for this pricing tier. When the order quantity meets or exceeds
|
|
28
|
+
* this threshold, the tier's price is applied.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* if (Item.Quantity >= tier.Quantity) {
|
|
32
|
+
* return tier.Price; // Use tier pricing
|
|
33
|
+
* }
|
|
34
|
+
*/
|
|
35
|
+
Quantity: number;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* The price for this tier.
|
|
39
|
+
* This value represents the unit price that applies when the order
|
|
40
|
+
* quantity meets or exceeds the tier's quantity threshold.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* var tier = HelperMethods.FindTier(Item.Quantity, Item.PricingTiers);
|
|
44
|
+
* if (tier) {
|
|
45
|
+
* return tier.Price * Item.Quantity;
|
|
46
|
+
* }
|
|
47
|
+
*/
|
|
48
|
+
Price: number;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* The customer role system name that this tier applies to.
|
|
52
|
+
* This value is empty when the tier applies to all customer roles.
|
|
53
|
+
* When specified, the tier only applies to customers with the
|
|
54
|
+
* specified role, allowing for role-based pricing strategies.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* if (tier.CustomerRole === "" || Customer.CustomerRoles.includes(tier.CustomerRole)) {
|
|
58
|
+
* return tier.Price; // Tier applies to this customer
|
|
59
|
+
* }
|
|
60
|
+
*/
|
|
61
|
+
CustomerRole: string;
|
|
62
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This module provides access to version management functionality in pricing scripts.
|
|
3
|
+
* The version system supports job versioning information including quantities
|
|
4
|
+
* and custom names, useful for tracking pricing changes across job iterations including:
|
|
5
|
+
* - Individual version information
|
|
6
|
+
* - Version collection management
|
|
7
|
+
* - Quantity tracking across versions
|
|
8
|
+
* - Version status and metadata
|
|
9
|
+
*
|
|
10
|
+
* @module Item / Version
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Represents individual version item information.
|
|
15
|
+
* Each version item contains details about a specific version of a job,
|
|
16
|
+
* including its unique identifier, custom name, and quantity information.
|
|
17
|
+
*
|
|
18
|
+
* Version items are used to track different iterations or variations
|
|
19
|
+
* of the same job, allowing for complex pricing scenarios where
|
|
20
|
+
* multiple versions of a product are being ordered simultaneously.
|
|
21
|
+
*/
|
|
22
|
+
declare interface ItemVersion {
|
|
23
|
+
/**
|
|
24
|
+
* The job ID for this version.
|
|
25
|
+
* This unique identifier links this version to a specific job
|
|
26
|
+
* in the system, allowing for tracking and management of
|
|
27
|
+
* individual version instances.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* var versionJobId = version.JobId;
|
|
31
|
+
* console.log("Processing version with job ID: " + versionJobId);
|
|
32
|
+
*/
|
|
33
|
+
JobId: string;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* The custom name for this version.
|
|
37
|
+
* This human-readable identifier allows users to distinguish
|
|
38
|
+
* between different versions of the same job, such as
|
|
39
|
+
* "Draft Version", "Final Version", or "Client Approved".
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* var versionName = version.CustomName;
|
|
43
|
+
* if (versionName.includes("Final")) {
|
|
44
|
+
* return Item.Price * 1.1; // 10% markup for final versions
|
|
45
|
+
* }
|
|
46
|
+
*/
|
|
47
|
+
CustomName: string;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* The quantity for this version.
|
|
51
|
+
* This value represents how many units of this specific version
|
|
52
|
+
* are being ordered, allowing for version-specific quantity
|
|
53
|
+
* calculations and pricing adjustments.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* var versionQuantity = version.Quantity;
|
|
57
|
+
* var versionTotal = Item.Price * versionQuantity;
|
|
58
|
+
*/
|
|
59
|
+
Quantity: number;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Represents version data containing comprehensive version information.
|
|
64
|
+
* This interface provides access to version collection management,
|
|
65
|
+
* version status tracking, and aggregate quantity calculations
|
|
66
|
+
* across all versions of a job.
|
|
67
|
+
*
|
|
68
|
+
* Version data is essential for complex pricing scenarios where
|
|
69
|
+
* multiple versions of a product are being processed together,
|
|
70
|
+
* allowing for bulk pricing and version-specific adjustments.
|
|
71
|
+
*/
|
|
72
|
+
declare interface VersionData {
|
|
73
|
+
/**
|
|
74
|
+
* Collection of version items.
|
|
75
|
+
* This array contains all individual version items associated
|
|
76
|
+
* with the current job, providing access to detailed information
|
|
77
|
+
* about each version including quantities and custom names.
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* var totalPrice = 0;
|
|
81
|
+
* for (var i = 0; i < versionData.Versions.length; i++) {
|
|
82
|
+
* var version = versionData.Versions[i];
|
|
83
|
+
* totalPrice += Item.Price * version.Quantity;
|
|
84
|
+
* }
|
|
85
|
+
* return totalPrice;
|
|
86
|
+
*/
|
|
87
|
+
Versions: ItemVersion[];
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Indicates whether this is a version of a job.
|
|
91
|
+
* This boolean flag determines if the current job is part of
|
|
92
|
+
* a versioned workflow, affecting how pricing calculations
|
|
93
|
+
* and business logic should be applied.
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* if (versionData.IsVersion) {
|
|
97
|
+
* // Apply version-specific pricing logic
|
|
98
|
+
* return calculateVersionPricing(versionData);
|
|
99
|
+
* }
|
|
100
|
+
*/
|
|
101
|
+
IsVersion: boolean;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* The number of versions in the collection.
|
|
105
|
+
* This value provides a quick count of how many versions
|
|
106
|
+
* are associated with the current job, useful for bulk
|
|
107
|
+
* pricing calculations and version management.
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* if (versionData.NumberOfVersions > 1) {
|
|
111
|
+
* return Item.Price * 0.95; // 5% discount for multiple versions
|
|
112
|
+
* }
|
|
113
|
+
*/
|
|
114
|
+
NumberOfVersions: number;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* The sum of all quantities across all versions.
|
|
118
|
+
* This value represents the total quantity being ordered
|
|
119
|
+
* across all versions of the job, useful for bulk pricing
|
|
120
|
+
* and quantity-based discount calculations.
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* var totalQuantity = versionData.VersionsSumQuantity;
|
|
124
|
+
* var tier = HelperMethods.FindTier(totalQuantity, Item.PricingTiers);
|
|
125
|
+
* if (tier) {
|
|
126
|
+
* return tier.Price * totalQuantity;
|
|
127
|
+
* }
|
|
128
|
+
*/
|
|
129
|
+
VersionsSumQuantity: number;
|
|
130
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This module provides access to configuration settings in pricing scripts.
|
|
3
|
+
* The Configuration object allows scripts to access and utilize various
|
|
4
|
+
* configuration parameters that control script behavior including:
|
|
5
|
+
* - Script-specific configuration settings
|
|
6
|
+
* - Environment variables and parameters
|
|
7
|
+
* - Custom configuration data
|
|
8
|
+
* - System-wide settings
|
|
9
|
+
*
|
|
10
|
+
* @module System / Configuration
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Provides access to script configuration settings and parameters.
|
|
15
|
+
* This interface allows pricing scripts to retrieve configuration data
|
|
16
|
+
* that controls their behavior and functionality.
|
|
17
|
+
*
|
|
18
|
+
* Configuration settings can include script-specific parameters,
|
|
19
|
+
* environment variables, and custom configuration data that affects
|
|
20
|
+
* how the pricing script operates.
|
|
21
|
+
*/
|
|
22
|
+
declare interface ConfigurationInterface {
|
|
23
|
+
/**
|
|
24
|
+
* The script configuration object containing all configuration settings.
|
|
25
|
+
* This object holds various configuration parameters that can be used
|
|
26
|
+
* to customize script behavior and access external configuration data.
|
|
27
|
+
*
|
|
28
|
+
* The structure of this object depends on the specific configuration
|
|
29
|
+
* settings defined for the pricing script.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* var config = Configuration.ScriptConfig;
|
|
33
|
+
* var markupPercentage = config.markupPercentage || 20;
|
|
34
|
+
* var baseShippingCost = config.baseShippingCost || 5.99;
|
|
35
|
+
*/
|
|
36
|
+
ScriptConfig: any;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Global Configuration object available in pricing scripts.
|
|
41
|
+
* This constant provides access to the configuration interface,
|
|
42
|
+
* allowing scripts to retrieve configuration settings and parameters.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* var scriptConfig = Configuration.ScriptConfig;
|
|
46
|
+
* var customSetting = scriptConfig.customParameter;
|
|
47
|
+
*/
|
|
48
|
+
declare const Configuration: ConfigurationInterface;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This module provides access to output and messaging functionality in pricing scripts.
|
|
3
|
+
* The output functions allow scripts to communicate with users and provide feedback
|
|
4
|
+
* about pricing calculations and decisions including:
|
|
5
|
+
* - Debug messages for development and troubleshooting
|
|
6
|
+
* - Alert messages for important information
|
|
7
|
+
* - Warning messages for potential issues
|
|
8
|
+
* - Error messages for calculation failures
|
|
9
|
+
* - Console logging for debugging purposes
|
|
10
|
+
*
|
|
11
|
+
* @module System / Output
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Output a debug message to the user interface.
|
|
16
|
+
* Debug messages are typically used during development and troubleshooting
|
|
17
|
+
* to provide detailed information about script execution and calculations.
|
|
18
|
+
*
|
|
19
|
+
* @param message - The debug message to display to the user
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* debug("Calculating price for item: " + Item.ProductName);
|
|
23
|
+
* debug("Base price: $" + Item.Price + ", Quantity: " + Item.Quantity);
|
|
24
|
+
*/
|
|
25
|
+
declare function debug(message: string): void;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Output an alert message to the user interface.
|
|
29
|
+
* Alert messages are used to display important information that requires
|
|
30
|
+
* user attention, such as pricing changes or special offers.
|
|
31
|
+
*
|
|
32
|
+
* @param message - The alert message to display to the user
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* alert("Special pricing applied: 20% discount for bulk orders");
|
|
36
|
+
* alert("Price updated based on selected attributes");
|
|
37
|
+
*/
|
|
38
|
+
declare function alert(message: string): void;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Output a warning message to the user interface.
|
|
42
|
+
* Warning messages are used to notify users about potential issues
|
|
43
|
+
* or important considerations that may affect their pricing.
|
|
44
|
+
*
|
|
45
|
+
* @param message - The warning message to display to the user
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* warning("Large file detected - processing may take longer");
|
|
49
|
+
* warning("Some attributes may affect shipping costs");
|
|
50
|
+
*/
|
|
51
|
+
declare function warning(message: string): void;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Output an error message to the user interface.
|
|
55
|
+
* Error messages are used to inform users about calculation failures
|
|
56
|
+
* or other issues that prevent normal pricing execution.
|
|
57
|
+
*
|
|
58
|
+
* @param message - The error message to display to the user
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* error("Unable to calculate price - missing required attributes");
|
|
62
|
+
* error("File processing failed - please check file format");
|
|
63
|
+
*/
|
|
64
|
+
declare function error(message: string): void;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Output a message to the browser console/logs.
|
|
68
|
+
* Console messages are used for debugging purposes and are typically
|
|
69
|
+
* only visible to developers in the browser's developer tools.
|
|
70
|
+
*
|
|
71
|
+
* @param message - The message to log to the console
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* consoleLog("Script execution started");
|
|
75
|
+
* consoleLog("Final calculated price: $" + finalPrice);
|
|
76
|
+
*/
|
|
77
|
+
declare function consoleLog(message: string): void;
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
package/v1/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference path="Item/Item.d.ts" />
|
|
2
|
+
/// <reference path="Item/Attribute.d.ts" />
|
|
3
|
+
/// <reference path="Item/Tier.d.ts" />
|
|
4
|
+
/// <reference path="Item/Version.d.ts" />
|
|
5
|
+
/// <reference path="File/FileInfo.d.ts" />
|
|
6
|
+
/// <reference path="System/Configuration.d.ts" />
|
|
7
|
+
/// <reference path="System/Output.d.ts" />
|
|
8
|
+
/// <reference path="Helper/HelperMethods.d.ts" />
|