expensify-common 2.0.182 → 2.0.184
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/API.js +19 -24
- package/dist/APIDeferred.js +5 -5
- package/dist/CLI.d.ts +160 -0
- package/dist/CLI.js +282 -0
- package/dist/CONST.js +1 -1
- package/dist/Cookie.d.ts +5 -5
- package/dist/Cookie.js +6 -6
- package/dist/ExpenseRule.d.ts +10 -10
- package/dist/ExpenseRule.js +9 -9
- package/dist/ExpensiMark.d.ts +23 -51
- package/dist/ExpensiMark.js +311 -333
- package/dist/Func.js +3 -1
- package/dist/Log.js +1 -1
- package/dist/Logger.d.ts +2 -2
- package/dist/Logger.js +6 -4
- package/dist/Network.js +10 -10
- package/dist/Num.d.ts +1 -1
- package/dist/Num.js +9 -5
- package/dist/PageEvent.d.ts +2 -2
- package/dist/PageEvent.js +1 -1
- package/dist/PubSub.js +7 -7
- package/dist/ReportHistoryStore.d.ts +8 -71
- package/dist/ReportHistoryStore.js +106 -180
- package/dist/SafeString.d.ts +8 -0
- package/dist/SafeString.js +52 -0
- package/dist/Templates.d.ts +13 -13
- package/dist/Templates.js +157 -183
- package/dist/components/StepProgressBar.d.ts +8 -4
- package/dist/components/StepProgressBar.js +4 -3
- package/dist/components/form/element/combobox.d.ts +1 -8
- package/dist/components/form/element/combobox.js +37 -37
- package/dist/components/form/element/switch.d.ts +2 -2
- package/dist/components/form/element/switch.js +7 -5
- package/dist/fastMerge.js +0 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.js +5 -2
- package/dist/jquery.expensifyIframify.d.ts +1 -2
- package/dist/jquery.expensifyIframify.js +13 -15
- package/dist/md5.js +30 -29
- package/dist/mixins/PubSub.js +2 -2
- package/dist/str.d.ts +31 -0
- package/dist/str.js +69 -19
- package/dist/utils.d.ts +4 -4
- package/dist/utils.js +6 -6
- package/package.json +12 -10
package/dist/Cookie.js
CHANGED
|
@@ -60,7 +60,7 @@ function set(name, value, expiredays) {
|
|
|
60
60
|
* Detects if cookies are currently enabled in the browser
|
|
61
61
|
* by trying to create a cookie, see if it exists, and delete it afterwards again.
|
|
62
62
|
*
|
|
63
|
-
* @
|
|
63
|
+
* @returns {Boolean} True if cookies are enabled, otherwise false.
|
|
64
64
|
*/
|
|
65
65
|
function enabled() {
|
|
66
66
|
// Check they have cookies enabled
|
|
@@ -77,7 +77,7 @@ function enabled() {
|
|
|
77
77
|
* Fetches the value of a cookie.
|
|
78
78
|
*
|
|
79
79
|
* @param {String} name The name of the cookie to fetch.
|
|
80
|
-
* @
|
|
80
|
+
* @returns {String|null} The value of the cookie.
|
|
81
81
|
*/
|
|
82
82
|
function get(name) {
|
|
83
83
|
if (!name || document.cookie.length <= 0) {
|
|
@@ -103,14 +103,14 @@ function get(name) {
|
|
|
103
103
|
* @param {String} name
|
|
104
104
|
* @param {Any|null} defaultValue
|
|
105
105
|
*
|
|
106
|
-
* @
|
|
106
|
+
* @returns {Any|null}
|
|
107
107
|
*/
|
|
108
108
|
function getJSON(name, defaultValue = null) {
|
|
109
109
|
let data;
|
|
110
110
|
try {
|
|
111
111
|
data = JSON.parse(get(name));
|
|
112
112
|
}
|
|
113
|
-
catch (
|
|
113
|
+
catch (_a) {
|
|
114
114
|
data = defaultValue;
|
|
115
115
|
}
|
|
116
116
|
return data;
|
|
@@ -119,7 +119,7 @@ function getJSON(name, defaultValue = null) {
|
|
|
119
119
|
* Find a cookie that has been set.
|
|
120
120
|
*
|
|
121
121
|
* @param {String} name Name of the cookie to find
|
|
122
|
-
* @
|
|
122
|
+
* @returns {Boolean} Whether or not the cookie is set
|
|
123
123
|
*/
|
|
124
124
|
function has(name) {
|
|
125
125
|
return get(name) !== null;
|
|
@@ -127,7 +127,7 @@ function has(name) {
|
|
|
127
127
|
/**
|
|
128
128
|
* Returns help link when cookies are enabled or null.
|
|
129
129
|
*
|
|
130
|
-
* @
|
|
130
|
+
* @returns {(String|null)}
|
|
131
131
|
*/
|
|
132
132
|
function getHelpLink() {
|
|
133
133
|
if (enabled()) {
|
package/dist/ExpenseRule.d.ts
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
export default class ExpenseRule {
|
|
2
|
+
/**
|
|
3
|
+
* Checks the passed value against the actual based on what the condition (matches, greater, less than, etc.)
|
|
4
|
+
*
|
|
5
|
+
* @param {string} condition
|
|
6
|
+
* @param {Mixed} ruleValue
|
|
7
|
+
* @param {Mixed} transactionValue
|
|
8
|
+
* @returns {boolean}
|
|
9
|
+
*/
|
|
10
|
+
static checkCondition(condition: string, ruleValue: Mixed, transactionValue: Mixed): boolean;
|
|
2
11
|
/**
|
|
3
12
|
* Creates a new instance of this class.
|
|
4
13
|
*
|
|
@@ -11,7 +20,7 @@ export default class ExpenseRule {
|
|
|
11
20
|
*
|
|
12
21
|
* @param {string} field
|
|
13
22
|
*
|
|
14
|
-
* @
|
|
23
|
+
* @returns {Object}
|
|
15
24
|
*/
|
|
16
25
|
getApplyWhenByField(field: string): Object;
|
|
17
26
|
/**
|
|
@@ -27,13 +36,4 @@ export default class ExpenseRule {
|
|
|
27
36
|
* @returns {boolean}
|
|
28
37
|
*/
|
|
29
38
|
isMatch(expense: SExpense3): boolean;
|
|
30
|
-
/**
|
|
31
|
-
* Checks the passed value against the actual based on what the condition (matches, greater, less than, etc.)
|
|
32
|
-
*
|
|
33
|
-
* @param {string} condition
|
|
34
|
-
* @param {Mixed} ruleValue
|
|
35
|
-
* @param {Mixed} transactionValue
|
|
36
|
-
* @returns {boolean}
|
|
37
|
-
*/
|
|
38
|
-
checkCondition(condition: string, ruleValue: Mixed, transactionValue: Mixed): boolean;
|
|
39
39
|
}
|
package/dist/ExpenseRule.js
CHANGED
|
@@ -9,14 +9,14 @@ class ExpenseRule {
|
|
|
9
9
|
constructor(ruleArray) {
|
|
10
10
|
// It's not 100% certain that `ruleArray` is an array or an object, so support both of them so the app doesn't crash
|
|
11
11
|
if (Array.isArray(ruleArray)) {
|
|
12
|
-
ruleArray.
|
|
12
|
+
for (const [key, value] of ruleArray.entries()) {
|
|
13
13
|
this[key] = value;
|
|
14
|
-
}
|
|
14
|
+
}
|
|
15
15
|
}
|
|
16
16
|
else if (ruleArray && typeof ruleArray === 'object') {
|
|
17
|
-
Object.keys(ruleArray)
|
|
17
|
+
for (const key of Object.keys(ruleArray)) {
|
|
18
18
|
this[key] = ruleArray[key];
|
|
19
|
-
}
|
|
19
|
+
}
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
@@ -25,7 +25,7 @@ class ExpenseRule {
|
|
|
25
25
|
*
|
|
26
26
|
* @param {string} field
|
|
27
27
|
*
|
|
28
|
-
* @
|
|
28
|
+
* @returns {Object}
|
|
29
29
|
*/
|
|
30
30
|
getApplyWhenByField(field) {
|
|
31
31
|
return this.applyWhen.find((conditions) => conditions.field === field) || {};
|
|
@@ -46,17 +46,17 @@ class ExpenseRule {
|
|
|
46
46
|
*/
|
|
47
47
|
isMatch(expense) {
|
|
48
48
|
let isMatch = true;
|
|
49
|
-
this.applyWhen
|
|
49
|
+
for (const conditions of this.applyWhen) {
|
|
50
50
|
switch (conditions.field) {
|
|
51
51
|
case 'category':
|
|
52
|
-
if (!
|
|
52
|
+
if (!ExpenseRule.checkCondition(conditions.condition, conditions.value, expense.getCategory())) {
|
|
53
53
|
isMatch = false;
|
|
54
54
|
}
|
|
55
55
|
break;
|
|
56
56
|
default:
|
|
57
57
|
break;
|
|
58
58
|
}
|
|
59
|
-
}
|
|
59
|
+
}
|
|
60
60
|
return isMatch;
|
|
61
61
|
}
|
|
62
62
|
/**
|
|
@@ -67,7 +67,7 @@ class ExpenseRule {
|
|
|
67
67
|
* @param {Mixed} transactionValue
|
|
68
68
|
* @returns {boolean}
|
|
69
69
|
*/
|
|
70
|
-
checkCondition(condition, ruleValue, transactionValue) {
|
|
70
|
+
static checkCondition(condition, ruleValue, transactionValue) {
|
|
71
71
|
// Add more condition types (Greater than, Less than, Contains) below
|
|
72
72
|
switch (condition) {
|
|
73
73
|
case 'matches':
|
package/dist/ExpensiMark.d.ts
CHANGED
|
@@ -53,16 +53,25 @@ type TruncateOptions = {
|
|
|
53
53
|
slop?: number;
|
|
54
54
|
removeImageTag?: boolean;
|
|
55
55
|
};
|
|
56
|
+
declare function resolveAttributeCache(extras?: Extras): {
|
|
57
|
+
attrCachingFn: ((vidSource: string, attrs: string) => void) | undefined;
|
|
58
|
+
attrCache: Record<string, string> | undefined;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* replace block element with '\n' if :
|
|
62
|
+
* 1. We have text within the element.
|
|
63
|
+
* 2. The text does not end with a new line.
|
|
64
|
+
* 3. It's not the last element in the string.
|
|
65
|
+
*/
|
|
66
|
+
declare function replaceBlockElementWithNewLine(htmlString: string): string;
|
|
67
|
+
/** Check if the input text includes only the open or the close tag of an element. */
|
|
68
|
+
declare function containsNonPairTag(textToCheck: string): boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Truncate HTML string and keep tag safe.
|
|
71
|
+
* pulled from https://github.com/huang47/nodejs-html-truncate/blob/master/lib/truncate.js
|
|
72
|
+
*/
|
|
73
|
+
declare function truncateHTML(html: string, maxLength: number, options?: TruncateOptions): string;
|
|
56
74
|
export default class ExpensiMark {
|
|
57
|
-
extractVictoryChartTags: (text: string) => {
|
|
58
|
-
text: string;
|
|
59
|
-
tags: string[];
|
|
60
|
-
};
|
|
61
|
-
restoreVictoryChartTags: (text: string, tags: string[]) => string;
|
|
62
|
-
getAttributeCache: (extras?: Extras) => {
|
|
63
|
-
attrCachingFn: ((vidSource: string, attrs: string) => void) | undefined;
|
|
64
|
-
attrCache: Record<string, string> | undefined;
|
|
65
|
-
};
|
|
66
75
|
static Log: Logger;
|
|
67
76
|
/**
|
|
68
77
|
* Set the logger to use for logging inside of the ExpensiMark class
|
|
@@ -129,13 +138,6 @@ export default class ExpensiMark {
|
|
|
129
138
|
* Checks matched Emails for validity and replace valid links with html elements
|
|
130
139
|
*/
|
|
131
140
|
modifyTextForEmailLinks(regex: RegExp, textToCheck: string, replacement: ReplacementFn, shouldKeepRawInput: boolean): string;
|
|
132
|
-
/**
|
|
133
|
-
* replace block element with '\n' if :
|
|
134
|
-
* 1. We have text within the element.
|
|
135
|
-
* 2. The text does not end with a new line.
|
|
136
|
-
* 3. It's not the last element in the string.
|
|
137
|
-
*/
|
|
138
|
-
replaceBlockElementWithNewLine(htmlString: string): string;
|
|
139
141
|
/**
|
|
140
142
|
* Unpacks nested quote HTML tags that have been packed by the 'quote' rule in this.rules for shouldKeepRawInput = false
|
|
141
143
|
*
|
|
@@ -156,7 +158,7 @@ export default class ExpensiMark {
|
|
|
156
158
|
* Note that there will always be only a single closing tag, even if multiple opening tags exist.
|
|
157
159
|
* Only one closing tag is needed to detect if a nested quote has ended.
|
|
158
160
|
*/
|
|
159
|
-
unpackNestedQuotes(text: string): string;
|
|
161
|
+
static unpackNestedQuotes(text: string): string;
|
|
160
162
|
/**
|
|
161
163
|
* Replaces HTML with markdown
|
|
162
164
|
*/
|
|
@@ -174,10 +176,10 @@ export default class ExpensiMark {
|
|
|
174
176
|
replacedText: string;
|
|
175
177
|
shouldAddSpace: boolean;
|
|
176
178
|
};
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
179
|
+
getAttributeCache: typeof resolveAttributeCache;
|
|
180
|
+
replaceBlockElementWithNewLine: typeof replaceBlockElementWithNewLine;
|
|
181
|
+
containsNonPairTag: typeof containsNonPairTag;
|
|
182
|
+
truncateHTML: typeof truncateHTML;
|
|
181
183
|
/**
|
|
182
184
|
* @returns array or undefined if exception occurs when executing regex matching
|
|
183
185
|
*/
|
|
@@ -192,34 +194,4 @@ export default class ExpensiMark {
|
|
|
192
194
|
* @returns original MD content escaped for use in HTML attribute value
|
|
193
195
|
*/
|
|
194
196
|
escapeAttributeContent(content: string): string;
|
|
195
|
-
/**
|
|
196
|
-
* Determines the end position to truncate the HTML content while considering word boundaries.
|
|
197
|
-
*
|
|
198
|
-
* @param {string} content - The HTML content to be truncated.
|
|
199
|
-
* @param {number} tailPosition - The position up to which the content should be considered.
|
|
200
|
-
* @param {number} maxLength - The maximum length of the truncated content.
|
|
201
|
-
* @param {number} totalLength - The length of the content processed so far.
|
|
202
|
-
* @param {Object} opts - Options to customize the truncation.
|
|
203
|
-
* @returns {number} The calculated position to truncate the content.
|
|
204
|
-
*/
|
|
205
|
-
getEndPosition(content: string, tailPosition: number | undefined, maxLength: number, totalLength: number, opts: TruncateOptions): number;
|
|
206
|
-
/**
|
|
207
|
-
* Truncate HTML string and keep tag safe.
|
|
208
|
-
* pulled from https://github.com/huang47/nodejs-html-truncate/blob/master/lib/truncate.js
|
|
209
|
-
*
|
|
210
|
-
* @param {string} html - The string that needs to be truncated
|
|
211
|
-
* @param {number} maxLength - Length of truncated string
|
|
212
|
-
* @param {Object} [options] - Optional configuration options
|
|
213
|
-
* @returns {string} The truncated string
|
|
214
|
-
*/
|
|
215
|
-
truncateHTML(html: string, maxLength: number, options?: TruncateOptions): string;
|
|
216
|
-
/**
|
|
217
|
-
* Replaces text with a replacement based on a regex
|
|
218
|
-
* @param text - The text to replace
|
|
219
|
-
* @param regexp - The regex to match
|
|
220
|
-
* @param extras - The extras object
|
|
221
|
-
* @param replacement - The replacement string or function
|
|
222
|
-
* @returns The replaced text
|
|
223
|
-
*/
|
|
224
|
-
replaceTextWithExtras(text: string, regexp: RegExp, extras: Extras, replacement: Replacement): string;
|
|
225
197
|
}
|