expensify-common 2.0.181 → 2.0.183
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/CONST.d.ts +3 -0
- package/dist/CONST.js +4 -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/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.js +0 -1
- 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.js +19 -19
- package/dist/utils.d.ts +4 -4
- package/dist/utils.js +6 -6
- package/package.json +11 -10
package/dist/API.js
CHANGED
|
@@ -106,18 +106,18 @@ function API(network, args) {
|
|
|
106
106
|
* @param {String} apiDeferred
|
|
107
107
|
*/
|
|
108
108
|
function attachJSONCodeCallbacks(apiDeferred) {
|
|
109
|
-
|
|
109
|
+
for (const [code, callbacks] of Object.entries(defaultHandlers)) {
|
|
110
110
|
// The key, `code`, is returned as a string, so we must cast it to an Integer
|
|
111
111
|
const jsonCode = parseInt(code, 10);
|
|
112
|
-
|
|
112
|
+
for (const callback of callbacks) {
|
|
113
113
|
if (jsonCode === 200) {
|
|
114
114
|
apiDeferred.done(callback);
|
|
115
115
|
}
|
|
116
116
|
else {
|
|
117
117
|
apiDeferred.handle([jsonCode], callback);
|
|
118
118
|
}
|
|
119
|
-
}
|
|
120
|
-
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
121
|
}
|
|
122
122
|
/**
|
|
123
123
|
* @private
|
|
@@ -174,10 +174,9 @@ function API(network, args) {
|
|
|
174
174
|
* @param {String} commandName The name of the API command
|
|
175
175
|
*/
|
|
176
176
|
function requireParameters(parameterNames, parameters, commandName) {
|
|
177
|
-
|
|
178
|
-
parameterNames.forEach((parameterName) => {
|
|
177
|
+
for (const parameterName of parameterNames) {
|
|
179
178
|
if ((0, has_1.default)(parameters, parameterName) && parameters[parameterName] !== null && parameters[parameterName] !== undefined) {
|
|
180
|
-
|
|
179
|
+
continue;
|
|
181
180
|
}
|
|
182
181
|
const parametersCopy = Object.assign({}, parameters);
|
|
183
182
|
if ((0, has_1.default)(parametersCopy, 'authToken')) {
|
|
@@ -188,7 +187,7 @@ function API(network, args) {
|
|
|
188
187
|
}
|
|
189
188
|
const keys = Object.keys(parametersCopy).join(', ') || 'none';
|
|
190
189
|
throw new Error(`Parameter ${parameterName} is required for "${commandName}". Supplied parameters: ${keys}`);
|
|
191
|
-
}
|
|
190
|
+
}
|
|
192
191
|
}
|
|
193
192
|
return {
|
|
194
193
|
/**
|
|
@@ -199,12 +198,12 @@ function API(network, args) {
|
|
|
199
198
|
if (!Utils.isFunction(callback)) {
|
|
200
199
|
return;
|
|
201
200
|
}
|
|
202
|
-
|
|
201
|
+
for (const jsonCode of jsonCodes) {
|
|
203
202
|
if (!defaultHandlers[jsonCode]) {
|
|
204
203
|
defaultHandlers[jsonCode] = [];
|
|
205
204
|
}
|
|
206
205
|
defaultHandlers[jsonCode].push(callback);
|
|
207
|
-
}
|
|
206
|
+
}
|
|
208
207
|
},
|
|
209
208
|
/**
|
|
210
209
|
* Whether or not the JS code version has changed on the server compared to what was loaded on the page.
|
|
@@ -240,7 +239,7 @@ function API(network, args) {
|
|
|
240
239
|
* @param {String} [data.returnedPropertyType]
|
|
241
240
|
* @param {Boolean} [data.checkCodeRevision]
|
|
242
241
|
*
|
|
243
|
-
* @
|
|
242
|
+
* @returns {Function}
|
|
244
243
|
*/
|
|
245
244
|
extendMethod: (data) => {
|
|
246
245
|
if (!data.commandName) {
|
|
@@ -256,14 +255,14 @@ function API(network, args) {
|
|
|
256
255
|
};
|
|
257
256
|
},
|
|
258
257
|
/**
|
|
259
|
-
* @
|
|
258
|
+
* @returns {Network}
|
|
260
259
|
*/
|
|
261
260
|
getNetwork() {
|
|
262
261
|
return network;
|
|
263
262
|
},
|
|
264
263
|
/**
|
|
265
264
|
* @param {Object} parameters
|
|
266
|
-
* @
|
|
265
|
+
* @returns {ExpensifyAPIDeferred}
|
|
267
266
|
*/
|
|
268
267
|
logToServer(parameters) {
|
|
269
268
|
const commandName = 'Log';
|
|
@@ -272,7 +271,7 @@ function API(network, args) {
|
|
|
272
271
|
/**
|
|
273
272
|
* @param {Object} parameters
|
|
274
273
|
* @param {String} parameters.email
|
|
275
|
-
* @
|
|
274
|
+
* @returns {ExpensifyAPIDeferred}
|
|
276
275
|
*/
|
|
277
276
|
getAccountStatus(parameters) {
|
|
278
277
|
const commandName = 'GetAccountStatus';
|
|
@@ -284,7 +283,7 @@ function API(network, args) {
|
|
|
284
283
|
/**
|
|
285
284
|
* @param {Object} parameters
|
|
286
285
|
* @param {String} parameters.email
|
|
287
|
-
* @
|
|
286
|
+
* @returns {ExpensifyAPIDeferred}
|
|
288
287
|
*/
|
|
289
288
|
Domain_RequestAccess(parameters) {
|
|
290
289
|
const commandName = 'Domain_RequestAccess';
|
|
@@ -327,9 +326,7 @@ function API(network, args) {
|
|
|
327
326
|
/**
|
|
328
327
|
* Performs API command "Get"
|
|
329
328
|
*
|
|
330
|
-
* @param {Object} parameters The API call parameters, must contain "returnValueList"
|
|
331
|
-
* @param {Domain} [domain] If you want to run this command as the domain account of this domain
|
|
332
|
-
* @param {DomainMember} [domainMember] If you want to run this command as specified domain member
|
|
329
|
+
* @param {Object} parameters The API call parameters, must contain "returnValueList". May also include "domain" and "domainMember".
|
|
333
330
|
*
|
|
334
331
|
* @returns {APIDeferred} An APIDeferred representing the promise of this request
|
|
335
332
|
*/
|
|
@@ -394,7 +391,7 @@ function API(network, args) {
|
|
|
394
391
|
* @param {Object} parameters
|
|
395
392
|
* @param {String} [parameters.email]
|
|
396
393
|
*
|
|
397
|
-
* @
|
|
394
|
+
* @returns {ExpensifyAPIDeferred}
|
|
398
395
|
*/
|
|
399
396
|
resendValidateCode(parameters = {}) {
|
|
400
397
|
const commandName = 'ResendValidateCode';
|
|
@@ -406,7 +403,7 @@ function API(network, args) {
|
|
|
406
403
|
* @param {Object} parameters
|
|
407
404
|
* @param {String} parameters.email
|
|
408
405
|
*
|
|
409
|
-
* @
|
|
406
|
+
* @returns {ExpensifyAPIDeferred}
|
|
410
407
|
*/
|
|
411
408
|
reopenAccount(parameters) {
|
|
412
409
|
const commandName = 'User_ReopenAccount';
|
|
@@ -442,9 +439,7 @@ function API(network, args) {
|
|
|
442
439
|
/**
|
|
443
440
|
* Validate a user
|
|
444
441
|
*
|
|
445
|
-
* @param {Object} parameters
|
|
446
|
-
* @param {String} validateCode
|
|
447
|
-
* @param {Number} accountID
|
|
442
|
+
* @param {Object} parameters Must contain validateCode and accountID
|
|
448
443
|
* @returns {ExpensifyAPIDeferred}
|
|
449
444
|
*/
|
|
450
445
|
validateEmail(parameters) {
|
|
@@ -517,7 +512,7 @@ function API(network, args) {
|
|
|
517
512
|
* Performs API command GetRequestCountryCode
|
|
518
513
|
* Fetches the country code based on the location of the request
|
|
519
514
|
*
|
|
520
|
-
* @
|
|
515
|
+
* @returns {APIDeferred}
|
|
521
516
|
*/
|
|
522
517
|
getRequestCountryCode() {
|
|
523
518
|
const commandName = 'GetRequestCountryCode';
|
package/dist/APIDeferred.js
CHANGED
|
@@ -42,6 +42,7 @@ exports.default = APIDeferred;
|
|
|
42
42
|
* WIP, This is in the process of migration from web-e. Please add methods to this as is needed.|
|
|
43
43
|
* ----------------------------------------------------------------------------------------------
|
|
44
44
|
*/
|
|
45
|
+
const get_1 = __importDefault(require("lodash/get"));
|
|
45
46
|
const once_1 = __importDefault(require("lodash/once"));
|
|
46
47
|
const Utils = __importStar(require("./utils"));
|
|
47
48
|
const Func = __importStar(require("./Func"));
|
|
@@ -83,9 +84,8 @@ function APIDeferred(promise, extractedProperty) {
|
|
|
83
84
|
* @param {Object} [response]
|
|
84
85
|
*/
|
|
85
86
|
function handleError(jsonCode, response) {
|
|
86
|
-
var _a;
|
|
87
87
|
// Look for handlers for this error code
|
|
88
|
-
const handlers = (
|
|
88
|
+
const handlers = (0, get_1.default)(errorHandlers, jsonCode, []);
|
|
89
89
|
if (handlers.length > 0) {
|
|
90
90
|
Func.bulkInvoke(handlers, [jsonCode, response]);
|
|
91
91
|
}
|
|
@@ -192,15 +192,15 @@ function APIDeferred(promise, extractedProperty) {
|
|
|
192
192
|
*/
|
|
193
193
|
handle(jsonCodes, callback) {
|
|
194
194
|
if (Utils.isFunction(callback)) {
|
|
195
|
-
|
|
195
|
+
for (const code of jsonCodes) {
|
|
196
196
|
if (code === 200) {
|
|
197
|
-
|
|
197
|
+
continue;
|
|
198
198
|
}
|
|
199
199
|
if (!errorHandlers[code]) {
|
|
200
200
|
errorHandlers[code] = [];
|
|
201
201
|
}
|
|
202
202
|
errorHandlers[code].push((0, once_1.default)(callback));
|
|
203
|
-
}
|
|
203
|
+
}
|
|
204
204
|
ensureFutureCallbacksFire();
|
|
205
205
|
}
|
|
206
206
|
return this;
|
package/dist/CONST.d.ts
CHANGED
|
@@ -804,6 +804,9 @@ declare const CONST: {
|
|
|
804
804
|
readonly SUSPICIOUS_PAN_ENTRY: 8;
|
|
805
805
|
readonly SUSPICIOUS_PAN_ENTRY_CLEARED: 9;
|
|
806
806
|
readonly SUSPICIOUS_PAN_ENTRY_CONFIRMED: 10;
|
|
807
|
+
readonly SUSPICIOUS_TRANSACTIONS_DETECTED: 11;
|
|
808
|
+
readonly SUSPICIOUS_TRANSACTIONS_DETECTED_CLEARED: 12;
|
|
809
|
+
readonly SUSPICIOUS_TRANSACTIONS_DETECTED_CONFIRMED: 13;
|
|
807
810
|
};
|
|
808
811
|
};
|
|
809
812
|
readonly TRAVEL_BOOKING: {
|
package/dist/CONST.js
CHANGED
|
@@ -390,7 +390,7 @@ const CONST = {
|
|
|
390
390
|
*
|
|
391
391
|
* @type RegExp
|
|
392
392
|
*/
|
|
393
|
-
HYPERLINK:
|
|
393
|
+
HYPERLINK: /^(?:(?:(?:https?|ftp):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u00a1-\uffff][a-z0-9\u00a1-\uffff_-]{0,62})?[a-z0-9\u00a1-\uffff]\.)+(?:[a-z\u00a1-\uffff]{2,}\.?))(?::\d{2,5})?(?:[/?#]\S*)?$/i,
|
|
394
394
|
/**
|
|
395
395
|
* Regex to match valid emails during markdown transformations
|
|
396
396
|
*
|
|
@@ -848,6 +848,9 @@ const CONST = {
|
|
|
848
848
|
SUSPICIOUS_PAN_ENTRY: 8,
|
|
849
849
|
SUSPICIOUS_PAN_ENTRY_CLEARED: 9,
|
|
850
850
|
SUSPICIOUS_PAN_ENTRY_CONFIRMED: 10,
|
|
851
|
+
SUSPICIOUS_TRANSACTIONS_DETECTED: 11,
|
|
852
|
+
SUSPICIOUS_TRANSACTIONS_DETECTED_CLEARED: 12,
|
|
853
|
+
SUSPICIOUS_TRANSACTIONS_DETECTED_CONFIRMED: 13,
|
|
851
854
|
},
|
|
852
855
|
},
|
|
853
856
|
TRAVEL_BOOKING: {
|
package/dist/Cookie.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ export default _default;
|
|
|
19
19
|
* Detects if cookies are currently enabled in the browser
|
|
20
20
|
* by trying to create a cookie, see if it exists, and delete it afterwards again.
|
|
21
21
|
*
|
|
22
|
-
* @
|
|
22
|
+
* @returns {Boolean} True if cookies are enabled, otherwise false.
|
|
23
23
|
*/
|
|
24
24
|
declare function enabled(): boolean;
|
|
25
25
|
/**
|
|
@@ -32,7 +32,7 @@ declare function remove(name: string): void;
|
|
|
32
32
|
* Fetches the value of a cookie.
|
|
33
33
|
*
|
|
34
34
|
* @param {String} name The name of the cookie to fetch.
|
|
35
|
-
* @
|
|
35
|
+
* @returns {String|null} The value of the cookie.
|
|
36
36
|
*/
|
|
37
37
|
declare function get(name: string): string | null;
|
|
38
38
|
/**
|
|
@@ -42,20 +42,20 @@ declare function get(name: string): string | null;
|
|
|
42
42
|
* @param {String} name
|
|
43
43
|
* @param {Any|null} defaultValue
|
|
44
44
|
*
|
|
45
|
-
* @
|
|
45
|
+
* @returns {Any|null}
|
|
46
46
|
*/
|
|
47
47
|
declare function getJSON(name: string, defaultValue?: Any | null): Any | null;
|
|
48
48
|
/**
|
|
49
49
|
* Find a cookie that has been set.
|
|
50
50
|
*
|
|
51
51
|
* @param {String} name Name of the cookie to find
|
|
52
|
-
* @
|
|
52
|
+
* @returns {Boolean} Whether or not the cookie is set
|
|
53
53
|
*/
|
|
54
54
|
declare function has(name: string): boolean;
|
|
55
55
|
/**
|
|
56
56
|
* Returns help link when cookies are enabled or null.
|
|
57
57
|
*
|
|
58
|
-
* @
|
|
58
|
+
* @returns {(String|null)}
|
|
59
59
|
*/
|
|
60
60
|
declare function getHelpLink(): (string | null);
|
|
61
61
|
/**
|
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
|
}
|