expensify-common 2.0.14 → 2.0.16
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 +48 -24
- package/dist/APIDeferred.js +48 -27
- package/dist/BrowserDetect.js +26 -3
- package/dist/CONST.d.ts +1 -0
- package/dist/CONST.js +1 -0
- package/dist/ExpenseRule.js +3 -7
- package/dist/ExpensiMark.d.ts +8 -0
- package/dist/ExpensiMark.js +88 -43
- package/dist/Func.d.ts +2 -2
- package/dist/Func.js +33 -10
- package/dist/Log.js +27 -5
- package/dist/Logger.js +3 -2
- package/dist/Network.js +32 -10
- package/dist/Num.js +1 -2
- package/dist/PubSub.js +34 -11
- package/dist/ReportHistoryStore.js +11 -15
- package/dist/Templates.js +34 -11
- package/dist/components/StepProgressBar.js +2 -3
- package/dist/components/form/element/combobox.d.ts +1 -0
- package/dist/components/form/element/combobox.js +61 -35
- package/dist/components/form/element/dropdown.js +3 -3
- package/dist/components/form/element/switch.js +3 -5
- package/dist/mixins/PubSub.d.ts +2 -2
- package/dist/mixins/PubSub.js +30 -5
- package/dist/mixins/extraClasses.js +25 -2
- package/dist/str.js +3 -15
- package/dist/utils.d.ts +26 -1
- package/dist/utils.js +60 -1
- package/package.json +2 -3
package/dist/API.js
CHANGED
|
@@ -1,18 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
2
|
/**
|
|
7
3
|
* ----------------------------------------------------------------------------------------------
|
|
8
4
|
* WIP, This is in the process of migration from web-e. Please add methods to this as is needed.|
|
|
9
5
|
* ----------------------------------------------------------------------------------------------
|
|
10
6
|
*/
|
|
11
|
-
|
|
7
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
+
if (k2 === undefined) k2 = k;
|
|
9
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
+
}
|
|
13
|
+
Object.defineProperty(o, k2, desc);
|
|
14
|
+
}) : (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
o[k2] = m[k];
|
|
17
|
+
}));
|
|
18
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
19
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
20
|
+
}) : function(o, v) {
|
|
21
|
+
o["default"] = v;
|
|
22
|
+
});
|
|
23
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
24
|
+
if (mod && mod.__esModule) return mod;
|
|
25
|
+
var result = {};
|
|
26
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
27
|
+
__setModuleDefault(result, mod);
|
|
28
|
+
return result;
|
|
29
|
+
};
|
|
30
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
31
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
32
|
+
};
|
|
33
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
34
|
// Use this deferred lib so we don't have a dependency on jQuery (so we can use this module in mobile)
|
|
13
35
|
const simply_deferred_1 = require("simply-deferred");
|
|
36
|
+
const lodash_1 = require("lodash");
|
|
14
37
|
const APIDeferred_1 = __importDefault(require("./APIDeferred"));
|
|
15
|
-
const
|
|
38
|
+
const Utils = __importStar(require("./utils"));
|
|
16
39
|
/**
|
|
17
40
|
* @param {Network} network
|
|
18
41
|
* @param {Object} [args]
|
|
@@ -40,14 +63,14 @@ function API(network, args) {
|
|
|
40
63
|
* Returns a promise that is rejected if a change is detected
|
|
41
64
|
* Otherwise, it is resolved successfully
|
|
42
65
|
*
|
|
43
|
-
* @returns {Object}
|
|
66
|
+
* @returns {Object} Deferred
|
|
44
67
|
*/
|
|
45
68
|
function isRunningLatestVersionOfCode() {
|
|
46
69
|
const promise = new simply_deferred_1.Deferred();
|
|
47
70
|
network
|
|
48
71
|
.get('/revision.txt')
|
|
49
72
|
.done((codeRevision) => {
|
|
50
|
-
if (
|
|
73
|
+
if (Utils.isWindowAvailable() && codeRevision.trim() === window.CODE_REVISION) {
|
|
51
74
|
console.debug('Code revision is up to date');
|
|
52
75
|
promise.resolve();
|
|
53
76
|
}
|
|
@@ -72,7 +95,7 @@ function API(network, args) {
|
|
|
72
95
|
* @param {String} apiDeferred
|
|
73
96
|
*/
|
|
74
97
|
function attachJSONCodeCallbacks(apiDeferred) {
|
|
75
|
-
|
|
98
|
+
Object.entries(defaultHandlers).forEach(([code, callbacks]) => {
|
|
76
99
|
// The key, `code`, is returned as a string, so we must cast it to an Integer
|
|
77
100
|
const jsonCode = parseInt(code, 10);
|
|
78
101
|
callbacks.forEach((callback) => {
|
|
@@ -101,7 +124,7 @@ function API(network, args) {
|
|
|
101
124
|
function performPOSTRequest(command, parameters, returnedPropertyName, keepalive, checkCodeRevision) {
|
|
102
125
|
let newParameters = Object.assign(Object.assign({}, parameters), { command });
|
|
103
126
|
// If there was an enhanceParameters() method supplied in our args, then we will call that here
|
|
104
|
-
if (args &&
|
|
127
|
+
if (args && Utils.isFunction(args.enhanceParameters)) {
|
|
105
128
|
newParameters = args.enhanceParameters(newParameters);
|
|
106
129
|
}
|
|
107
130
|
// We need to setup multiple promises here depending on our arguments. If there is no argument, then we will just
|
|
@@ -142,17 +165,18 @@ function API(network, args) {
|
|
|
142
165
|
function requireParameters(parameterNames, parameters, commandName) {
|
|
143
166
|
// eslint-disable-next-line rulesdir/prefer-early-return
|
|
144
167
|
parameterNames.forEach((parameterName) => {
|
|
145
|
-
if (
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
throw new Error(`Parameter ${parameterName} is required for "${commandName}". Supplied parameters: ${keys}`);
|
|
168
|
+
if ((0, lodash_1.has)(parameters, parameterName) && parameters[parameterName] !== null && parameters[parameterName] !== undefined) {
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
const parametersCopy = Object.assign({}, parameters);
|
|
172
|
+
if ((0, lodash_1.has)(parametersCopy, 'authToken')) {
|
|
173
|
+
parametersCopy.authToken = '<redacted>';
|
|
174
|
+
}
|
|
175
|
+
if ((0, lodash_1.has)(parametersCopy, 'password')) {
|
|
176
|
+
parametersCopy.password = '<redacted>';
|
|
155
177
|
}
|
|
178
|
+
const keys = Object.keys(parametersCopy).join(', ') || 'none';
|
|
179
|
+
throw new Error(`Parameter ${parameterName} is required for "${commandName}". Supplied parameters: ${keys}`);
|
|
156
180
|
});
|
|
157
181
|
}
|
|
158
182
|
return {
|
|
@@ -161,7 +185,7 @@ function API(network, args) {
|
|
|
161
185
|
* @param {Function} callback
|
|
162
186
|
*/
|
|
163
187
|
registerDefaultHandler(jsonCodes, callback) {
|
|
164
|
-
if (!
|
|
188
|
+
if (!Utils.isFunction(callback)) {
|
|
165
189
|
return;
|
|
166
190
|
}
|
|
167
191
|
jsonCodes.forEach((jsonCode) => {
|
|
@@ -213,7 +237,7 @@ function API(network, args) {
|
|
|
213
237
|
}
|
|
214
238
|
return (parameters, keepalive = false) => {
|
|
215
239
|
// Optional validate function for required logic before making the call. e.g. validating params in the front-end etc.
|
|
216
|
-
if (
|
|
240
|
+
if (Utils.isFunction(data.validate)) {
|
|
217
241
|
data.validate(parameters);
|
|
218
242
|
}
|
|
219
243
|
requireParameters(data.requireParameters || [], parameters, data.commandName);
|
|
@@ -243,7 +267,7 @@ function API(network, args) {
|
|
|
243
267
|
const commandName = 'GetAccountStatus';
|
|
244
268
|
requireParameters(['email'], parameters, commandName);
|
|
245
269
|
// Tell the API not to set cookies for this request
|
|
246
|
-
const newParameters =
|
|
270
|
+
const newParameters = Object.assign(Object.assign({}, parameters), { api_setCookie: false });
|
|
247
271
|
return performPOSTRequest(commandName, newParameters);
|
|
248
272
|
},
|
|
249
273
|
/**
|
|
@@ -387,7 +411,7 @@ function API(network, args) {
|
|
|
387
411
|
resetPassword(parameters) {
|
|
388
412
|
const commandName = 'ResetPassword';
|
|
389
413
|
requireParameters(['email'], parameters, commandName);
|
|
390
|
-
const newParameters =
|
|
414
|
+
const newParameters = Object.assign(Object.assign({}, parameters), { api_setCookie: false });
|
|
391
415
|
return performPOSTRequest(commandName, newParameters);
|
|
392
416
|
},
|
|
393
417
|
/**
|
package/dist/APIDeferred.js
CHANGED
|
@@ -1,15 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
26
|
/**
|
|
3
27
|
* ----------------------------------------------------------------------------------------------
|
|
4
28
|
* WIP, This is in the process of migration from web-e. Please add methods to this as is needed.|
|
|
5
29
|
* ----------------------------------------------------------------------------------------------
|
|
6
30
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
const underscore_1 = __importDefault(require("underscore"));
|
|
12
|
-
const Func_1 = require("./Func");
|
|
31
|
+
const lodash_1 = require("lodash");
|
|
32
|
+
const Utils = __importStar(require("./utils"));
|
|
33
|
+
const Func = __importStar(require("./Func"));
|
|
13
34
|
/**
|
|
14
35
|
* @param {jquery.Deferred} promise
|
|
15
36
|
* @param {String} [extractedProperty]
|
|
@@ -50,15 +71,15 @@ function APIDeferred(promise, extractedProperty) {
|
|
|
50
71
|
function handleError(jsonCode, response) {
|
|
51
72
|
// Look for handlers for this error code
|
|
52
73
|
const handlers = errorHandlers[jsonCode];
|
|
53
|
-
if (
|
|
54
|
-
|
|
74
|
+
if (handlers.length > 0) {
|
|
75
|
+
Func.bulkInvoke(handlers, [jsonCode, response]);
|
|
55
76
|
}
|
|
56
77
|
else {
|
|
57
78
|
// No explicit handlers, call the unhandled callbacks
|
|
58
|
-
|
|
79
|
+
Func.bulkInvoke(unhandledCallbacks, [jsonCode, response]);
|
|
59
80
|
}
|
|
60
81
|
// Always run the "fail" callbacks in case of error
|
|
61
|
-
|
|
82
|
+
Func.bulkInvoke(failCallbacks, [jsonCode, response]);
|
|
62
83
|
}
|
|
63
84
|
/**
|
|
64
85
|
* Called when network call succeeds or when a callback is added via any of the following methods after the promise is resolved:
|
|
@@ -71,8 +92,8 @@ function APIDeferred(promise, extractedProperty) {
|
|
|
71
92
|
let returnedData;
|
|
72
93
|
// Figure out if we need to extract a property from the response, and if it is there.
|
|
73
94
|
const jsonCode = extractJSONCode(response);
|
|
74
|
-
const propertyRequested = !
|
|
75
|
-
const requestedPropertyPresent = propertyRequested && response &&
|
|
95
|
+
const propertyRequested = !Number.isNull(extractedPropertyName);
|
|
96
|
+
const requestedPropertyPresent = propertyRequested && response && response[extractedPropertyName] !== undefined;
|
|
76
97
|
const propertyRequestedButMissing = propertyRequested && !requestedPropertyPresent;
|
|
77
98
|
// Save the response for any callbacks that might run in the future
|
|
78
99
|
cachedResponse = response;
|
|
@@ -81,9 +102,9 @@ function APIDeferred(promise, extractedProperty) {
|
|
|
81
102
|
// Get the data that was requested
|
|
82
103
|
returnedData = propertyRequested && requestedPropertyPresent ? response[extractedPropertyName] : response;
|
|
83
104
|
// And then run the success callbacks
|
|
84
|
-
|
|
105
|
+
Func.bulkInvoke(doneCallbacks, [returnedData]);
|
|
85
106
|
}
|
|
86
|
-
else if (
|
|
107
|
+
else if (jsonCode !== null && jsonCode !== 200) {
|
|
87
108
|
// Exception thrown, handle it
|
|
88
109
|
handleError(jsonCode, response);
|
|
89
110
|
}
|
|
@@ -98,7 +119,7 @@ function APIDeferred(promise, extractedProperty) {
|
|
|
98
119
|
}
|
|
99
120
|
}
|
|
100
121
|
// Always run the "always" callbacks
|
|
101
|
-
|
|
122
|
+
Func.bulkInvoke(alwaysCallbacks, [response]);
|
|
102
123
|
}
|
|
103
124
|
/**
|
|
104
125
|
* Re-runs the "done" flow with a saved response to ensure that all callbacks are invoked,
|
|
@@ -125,8 +146,8 @@ function APIDeferred(promise, extractedProperty) {
|
|
|
125
146
|
* @returns {APIDeferred} itself, for chaining
|
|
126
147
|
*/
|
|
127
148
|
done(callback) {
|
|
128
|
-
if (
|
|
129
|
-
doneCallbacks.push((0,
|
|
149
|
+
if (Utils.isFunction(callback)) {
|
|
150
|
+
doneCallbacks.push((0, lodash_1.once)(callback));
|
|
130
151
|
ensureFutureCallbacksFire();
|
|
131
152
|
}
|
|
132
153
|
return this;
|
|
@@ -139,8 +160,8 @@ function APIDeferred(promise, extractedProperty) {
|
|
|
139
160
|
* @returns {APIDeferred} itself, for chaining
|
|
140
161
|
*/
|
|
141
162
|
always(callback) {
|
|
142
|
-
if (
|
|
143
|
-
alwaysCallbacks.push((0,
|
|
163
|
+
if (Utils.isFunction(callback)) {
|
|
164
|
+
alwaysCallbacks.push((0, lodash_1.once)(callback));
|
|
144
165
|
ensureFutureCallbacksFire();
|
|
145
166
|
}
|
|
146
167
|
return this;
|
|
@@ -155,7 +176,7 @@ function APIDeferred(promise, extractedProperty) {
|
|
|
155
176
|
* @returns {APIDeferred} itself, for chaining
|
|
156
177
|
*/
|
|
157
178
|
handle(jsonCodes, callback) {
|
|
158
|
-
if (
|
|
179
|
+
if (Utils.isFunction(callback)) {
|
|
159
180
|
jsonCodes.forEach((code) => {
|
|
160
181
|
if (code === 200) {
|
|
161
182
|
return;
|
|
@@ -163,7 +184,7 @@ function APIDeferred(promise, extractedProperty) {
|
|
|
163
184
|
if (!errorHandlers[code]) {
|
|
164
185
|
errorHandlers[code] = [];
|
|
165
186
|
}
|
|
166
|
-
errorHandlers[code].push((0,
|
|
187
|
+
errorHandlers[code].push((0, lodash_1.once)(callback));
|
|
167
188
|
});
|
|
168
189
|
ensureFutureCallbacksFire();
|
|
169
190
|
}
|
|
@@ -177,8 +198,8 @@ function APIDeferred(promise, extractedProperty) {
|
|
|
177
198
|
* @returns {APIDeferred} itself, for chaining
|
|
178
199
|
*/
|
|
179
200
|
unhandled(callback) {
|
|
180
|
-
if (
|
|
181
|
-
unhandledCallbacks.push((0,
|
|
201
|
+
if (Utils.isFunction(callback)) {
|
|
202
|
+
unhandledCallbacks.push((0, lodash_1.once)(callback));
|
|
182
203
|
ensureFutureCallbacksFire();
|
|
183
204
|
}
|
|
184
205
|
return this;
|
|
@@ -192,8 +213,8 @@ function APIDeferred(promise, extractedProperty) {
|
|
|
192
213
|
* @returns {APIDeferred} itself, for chaining
|
|
193
214
|
*/
|
|
194
215
|
fail(callback) {
|
|
195
|
-
if (
|
|
196
|
-
failCallbacks.push((0,
|
|
216
|
+
if (Utils.isFunction(callback)) {
|
|
217
|
+
failCallbacks.push((0, lodash_1.once)(callback));
|
|
197
218
|
ensureFutureCallbacksFire();
|
|
198
219
|
}
|
|
199
220
|
return this;
|
|
@@ -208,10 +229,10 @@ function APIDeferred(promise, extractedProperty) {
|
|
|
208
229
|
then(callback) {
|
|
209
230
|
return promise.then((response) => {
|
|
210
231
|
const responseCode = extractJSONCode(response);
|
|
211
|
-
if (responseCode !== 200 || !
|
|
232
|
+
if (responseCode !== 200 || !Utils.isFunction(callback)) {
|
|
212
233
|
return;
|
|
213
234
|
}
|
|
214
|
-
|
|
235
|
+
Func.invoke(callback, [response]);
|
|
215
236
|
return this;
|
|
216
237
|
});
|
|
217
238
|
},
|
package/dist/BrowserDetect.js
CHANGED
|
@@ -1,6 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
26
|
+
const Utils = __importStar(require("./utils"));
|
|
4
27
|
const BROWSERS = {
|
|
5
28
|
EDGE: 'Edge',
|
|
6
29
|
CHROME: 'Chrome',
|
|
@@ -14,7 +37,7 @@ const MOBILE_PLATFORMS = {
|
|
|
14
37
|
android: 'android',
|
|
15
38
|
};
|
|
16
39
|
function searchString() {
|
|
17
|
-
if (!
|
|
40
|
+
if (!Utils.isWindowAvailable() || !Utils.isNavigatorAvailable()) {
|
|
18
41
|
return '';
|
|
19
42
|
}
|
|
20
43
|
const data = [
|
|
@@ -75,7 +98,7 @@ function searchString() {
|
|
|
75
98
|
return '';
|
|
76
99
|
}
|
|
77
100
|
function getMobileDevice() {
|
|
78
|
-
if (!
|
|
101
|
+
if (!Utils.isNavigatorAvailable() || !navigator.userAgent) {
|
|
79
102
|
return '';
|
|
80
103
|
}
|
|
81
104
|
const data = [
|
package/dist/CONST.d.ts
CHANGED
|
@@ -774,6 +774,7 @@ declare const CONST: {
|
|
|
774
774
|
readonly prompt: "What software are you moving to and why?";
|
|
775
775
|
};
|
|
776
776
|
};
|
|
777
|
+
readonly VIDEO_EXTENSIONS: readonly ["mp4", "mov", "avi", "wmv", "flv", "mkv", "webm", "3gp", "m4v", "mpg", "mpeg", "ogv"];
|
|
777
778
|
};
|
|
778
779
|
/**
|
|
779
780
|
* UI Constants
|
package/dist/CONST.js
CHANGED
package/dist/ExpenseRule.js
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const underscore_1 = __importDefault(require("underscore"));
|
|
7
3
|
class ExpenseRule {
|
|
8
4
|
/**
|
|
9
5
|
* Creates a new instance of this class.
|
|
@@ -11,7 +7,7 @@ class ExpenseRule {
|
|
|
11
7
|
* @param {Array} ruleArray
|
|
12
8
|
*/
|
|
13
9
|
constructor(ruleArray) {
|
|
14
|
-
|
|
10
|
+
ruleArray.forEach((value, key) => {
|
|
15
11
|
this[key] = value;
|
|
16
12
|
});
|
|
17
13
|
}
|
|
@@ -24,7 +20,7 @@ class ExpenseRule {
|
|
|
24
20
|
* @return {Object}
|
|
25
21
|
*/
|
|
26
22
|
getApplyWhenByField(field) {
|
|
27
|
-
return
|
|
23
|
+
return this.applyWhen.find((conditions) => conditions.field === field) || {};
|
|
28
24
|
}
|
|
29
25
|
/**
|
|
30
26
|
* Get the externalID saved deep in the tax field
|
|
@@ -42,7 +38,7 @@ class ExpenseRule {
|
|
|
42
38
|
*/
|
|
43
39
|
isMatch(expense) {
|
|
44
40
|
let isMatch = true;
|
|
45
|
-
|
|
41
|
+
this.applyWhen.forEach((conditions) => {
|
|
46
42
|
switch (conditions.field) {
|
|
47
43
|
case 'category':
|
|
48
44
|
if (!this.checkCondition(conditions.condition, conditions.value, expense.getCategory())) {
|
package/dist/ExpensiMark.d.ts
CHANGED
|
@@ -39,7 +39,13 @@ declare type Rule = {
|
|
|
39
39
|
declare type ExtrasObject = {
|
|
40
40
|
reportIDToName?: Record<string, string>;
|
|
41
41
|
accountIDToName?: Record<string, string>;
|
|
42
|
+
cacheVideoAttributes?: (vidSource: string, attrs: string) => void;
|
|
42
43
|
};
|
|
44
|
+
|
|
45
|
+
declare type ExtraParamsForReplaceFunc = {
|
|
46
|
+
videoAttributeCache?: Record<string, string>;
|
|
47
|
+
};
|
|
48
|
+
|
|
43
49
|
export default class ExpensiMark {
|
|
44
50
|
static Log: Logger;
|
|
45
51
|
static setLogger(logger: Logger): void;
|
|
@@ -66,11 +72,13 @@ export default class ExpensiMark {
|
|
|
66
72
|
filterRules,
|
|
67
73
|
shouldEscapeText,
|
|
68
74
|
shouldKeepRawInput,
|
|
75
|
+
extras,
|
|
69
76
|
}?: {
|
|
70
77
|
filterRules?: Name[];
|
|
71
78
|
disabledRules?: Name[];
|
|
72
79
|
shouldEscapeText?: boolean;
|
|
73
80
|
shouldKeepRawInput?: boolean;
|
|
81
|
+
extras?: ExtraParamsForReplaceFunc;
|
|
74
82
|
},
|
|
75
83
|
): string;
|
|
76
84
|
/**
|