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/Func.js
CHANGED
|
@@ -82,7 +82,9 @@ function invokeAsync(callback, args, scope) {
|
|
|
82
82
|
* @param {Array} [args]
|
|
83
83
|
*/
|
|
84
84
|
function bulkInvoke(callbacks, args) {
|
|
85
|
-
|
|
85
|
+
for (const callback of callbacks) {
|
|
86
|
+
invoke(callback, args);
|
|
87
|
+
}
|
|
86
88
|
}
|
|
87
89
|
/**
|
|
88
90
|
* Throws an uncaught error in an attempt to stop JS execution
|
package/dist/Log.js
CHANGED
|
@@ -48,7 +48,7 @@ const Utils = __importStar(require("./utils"));
|
|
|
48
48
|
* @param {Object} params
|
|
49
49
|
* @param {Object} params.parameters
|
|
50
50
|
* @param {String} params.message
|
|
51
|
-
* @
|
|
51
|
+
* @returns {Promise}
|
|
52
52
|
*/
|
|
53
53
|
function serverLoggingCallback(logger, params) {
|
|
54
54
|
return (0, API_1.default)((0, Network_1.default)('/api/')).logToServer(params);
|
package/dist/Logger.d.ts
CHANGED
|
@@ -61,8 +61,8 @@ export default class Logger {
|
|
|
61
61
|
/**
|
|
62
62
|
* Logs a warn.
|
|
63
63
|
*
|
|
64
|
-
* @param
|
|
65
|
-
* @param
|
|
64
|
+
* @param message The message to warn.
|
|
65
|
+
* @param parameters The parameters to send along with the message
|
|
66
66
|
*/
|
|
67
67
|
warn(message: string, parameters?: Parameters): void;
|
|
68
68
|
/**
|
package/dist/Logger.js
CHANGED
|
@@ -33,11 +33,13 @@ class Logger {
|
|
|
33
33
|
return l;
|
|
34
34
|
});
|
|
35
35
|
this.logLines = [];
|
|
36
|
-
const promise = this.serverLoggingCallback(this, {
|
|
36
|
+
const promise = this.serverLoggingCallback(this, {
|
|
37
|
+
api_setCookie: false,
|
|
38
|
+
logPacket: JSON.stringify(linesToLog),
|
|
39
|
+
});
|
|
37
40
|
if (!promise) {
|
|
38
41
|
return;
|
|
39
42
|
}
|
|
40
|
-
// eslint-disable-next-line rulesdir/prefer-early-return
|
|
41
43
|
promise.then((response) => {
|
|
42
44
|
if (!response.requestID) {
|
|
43
45
|
return;
|
|
@@ -107,8 +109,8 @@ class Logger {
|
|
|
107
109
|
/**
|
|
108
110
|
* Logs a warn.
|
|
109
111
|
*
|
|
110
|
-
* @param
|
|
111
|
-
* @param
|
|
112
|
+
* @param message The message to warn.
|
|
113
|
+
* @param parameters The parameters to send along with the message
|
|
112
114
|
*/
|
|
113
115
|
warn(message, parameters = '') {
|
|
114
116
|
const msg = `[warn] ${message}`;
|
package/dist/Network.js
CHANGED
|
@@ -113,16 +113,16 @@ function Network(endpoint) {
|
|
|
113
113
|
// Check to see if parameters contains a File or Blob object
|
|
114
114
|
// If it does, we should use formData instead of parameters and update
|
|
115
115
|
// the ajax settings accordingly
|
|
116
|
-
|
|
116
|
+
for (const [key, value] of Object.entries(parameters)) {
|
|
117
117
|
if (value === undefined) {
|
|
118
|
-
|
|
118
|
+
continue;
|
|
119
119
|
}
|
|
120
120
|
// Populate formData in case we need it
|
|
121
121
|
formData.append(key, value);
|
|
122
122
|
if (value instanceof File || value instanceof Blob) {
|
|
123
123
|
shouldUseFormData = true;
|
|
124
124
|
}
|
|
125
|
-
}
|
|
125
|
+
}
|
|
126
126
|
if (shouldUseFormData) {
|
|
127
127
|
settings.processData = false;
|
|
128
128
|
settings.contentType = false;
|
|
@@ -153,26 +153,26 @@ function Network(endpoint) {
|
|
|
153
153
|
url = addCommandToUrl(parameters.command, url);
|
|
154
154
|
// Add our data as form data
|
|
155
155
|
const formData = new FormData();
|
|
156
|
-
|
|
156
|
+
for (const [key, value] of Object.entries(parameters)) {
|
|
157
157
|
if (value === undefined) {
|
|
158
|
-
|
|
158
|
+
continue;
|
|
159
159
|
}
|
|
160
160
|
if (Array.isArray(value)) {
|
|
161
|
-
value.
|
|
161
|
+
for (const [i, valueItem] of value.entries()) {
|
|
162
162
|
if (Utils.isObject(valueItem)) {
|
|
163
|
-
|
|
163
|
+
for (const [valueItemObjectKey, valueItemObjectValue] of Object.entries(valueItem)) {
|
|
164
164
|
formData.append(`${key}[${i}][${valueItemObjectKey}]`, valueItemObjectValue);
|
|
165
|
-
}
|
|
165
|
+
}
|
|
166
166
|
}
|
|
167
167
|
else {
|
|
168
168
|
formData.append(`${key}[${i}]`, valueItem);
|
|
169
169
|
}
|
|
170
|
-
}
|
|
170
|
+
}
|
|
171
171
|
}
|
|
172
172
|
else {
|
|
173
173
|
formData.append(key, value);
|
|
174
174
|
}
|
|
175
|
-
}
|
|
175
|
+
}
|
|
176
176
|
settings.body = formData;
|
|
177
177
|
// Make our request via the fetch API but return it in the form of a jQuery promise
|
|
178
178
|
// so that our API can be consistent
|
package/dist/Num.d.ts
CHANGED
package/dist/Num.js
CHANGED
|
@@ -52,7 +52,8 @@ exports.default = {
|
|
|
52
52
|
let h = null;
|
|
53
53
|
let i = null;
|
|
54
54
|
let j = null;
|
|
55
|
-
|
|
55
|
+
const multiplier = Math.pow(10, b);
|
|
56
|
+
a = Math.round(a * multiplier) / multiplier;
|
|
56
57
|
if (a < 0) {
|
|
57
58
|
a *= -1;
|
|
58
59
|
sign = '-';
|
|
@@ -76,7 +77,8 @@ exports.default = {
|
|
|
76
77
|
h = f[0];
|
|
77
78
|
f[0] = '';
|
|
78
79
|
for (j = 3; j < h.length; j += 3) {
|
|
79
|
-
|
|
80
|
+
const sliceStart = h.length - j;
|
|
81
|
+
i = h.slice(sliceStart, sliceStart + 3);
|
|
80
82
|
f[0] = `${d}${i}${f[0]}`;
|
|
81
83
|
}
|
|
82
84
|
j = h.substr(0, h.length % 3 === 0 ? 3 : h.length % 3);
|
|
@@ -141,7 +143,7 @@ exports.default = {
|
|
|
141
143
|
* Returns how many decimals to display (used for currencies).
|
|
142
144
|
*
|
|
143
145
|
* @param {Number} rate
|
|
144
|
-
* @
|
|
146
|
+
* @returns {Number}
|
|
145
147
|
*/
|
|
146
148
|
getDisplayDecimals(rate) {
|
|
147
149
|
if (rate % 1 === 0) {
|
|
@@ -173,7 +175,8 @@ exports.default = {
|
|
|
173
175
|
* @returns {number} The amount of tax
|
|
174
176
|
*/
|
|
175
177
|
calculateTaxFromPercentage(total, percentage) {
|
|
176
|
-
const
|
|
178
|
+
const percentageAsDecimal = str_1.default.percentageStringToNumber(percentage) / 100;
|
|
179
|
+
const divisor = percentage ? percentageAsDecimal + 1 : 1;
|
|
177
180
|
return this.calculateTaxFromDivisor(total, divisor);
|
|
178
181
|
},
|
|
179
182
|
/**
|
|
@@ -185,7 +188,8 @@ exports.default = {
|
|
|
185
188
|
* @returns {number} The amount of tax
|
|
186
189
|
*/
|
|
187
190
|
calculateTaxFromDivisor(total, divisor) {
|
|
188
|
-
|
|
191
|
+
const amountExcludingTax = total / divisor;
|
|
192
|
+
return parseInt(Math.round(total - amountExcludingTax), 10);
|
|
189
193
|
},
|
|
190
194
|
},
|
|
191
195
|
};
|
package/dist/PageEvent.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*
|
|
6
6
|
* @param {String} eventName Name of the event to listen to
|
|
7
7
|
* @param {Function} callback Function to fire
|
|
8
|
-
* @
|
|
8
|
+
* @class
|
|
9
9
|
*/
|
|
10
10
|
export default function _default(eventName: string, callback: Function): {
|
|
11
11
|
subscribe(scope: any): void;
|
|
@@ -19,7 +19,7 @@ export default class _default {
|
|
|
19
19
|
*
|
|
20
20
|
* @param {String} eventName Name of the event to listen to
|
|
21
21
|
* @param {Function} callback Function to fire
|
|
22
|
-
* @
|
|
22
|
+
* @class
|
|
23
23
|
*/
|
|
24
24
|
constructor(eventName: string, callback: Function);
|
|
25
25
|
}
|
package/dist/PageEvent.js
CHANGED
|
@@ -12,7 +12,7 @@ const PubSub_1 = __importDefault(require("./PubSub"));
|
|
|
12
12
|
*
|
|
13
13
|
* @param {String} eventName Name of the event to listen to
|
|
14
14
|
* @param {Function} callback Function to fire
|
|
15
|
-
* @
|
|
15
|
+
* @class
|
|
16
16
|
*/
|
|
17
17
|
function default_1(eventName, callback) {
|
|
18
18
|
let id = null;
|
package/dist/PubSub.js
CHANGED
|
@@ -51,7 +51,7 @@ let counter = 0;
|
|
|
51
51
|
/**
|
|
52
52
|
* Create a unique ID for each event subscriber
|
|
53
53
|
* @param {String} eventName Name of the event to listen to
|
|
54
|
-
* @
|
|
54
|
+
* @returns {String} unique ID
|
|
55
55
|
*/
|
|
56
56
|
const generateID = (eventName) => {
|
|
57
57
|
counter++;
|
|
@@ -60,7 +60,7 @@ const generateID = (eventName) => {
|
|
|
60
60
|
/**
|
|
61
61
|
* Find the name of the event from the ID
|
|
62
62
|
* @param {string} eventID
|
|
63
|
-
* @
|
|
63
|
+
* @returns {String}
|
|
64
64
|
*/
|
|
65
65
|
const extractEventName = (eventID = '') => eventID.substring(0, eventID.indexOf('@#@'));
|
|
66
66
|
const PubSubModule = {
|
|
@@ -82,12 +82,12 @@ const PubSubModule = {
|
|
|
82
82
|
// When debugging, we just need to know who called PubSub.publish (so, all next elements in the stack)
|
|
83
83
|
Log_1.default.hmmm('Error published', 0, { tplt: param.tplt, stackTrace: new Error().stack.split(' at ').slice(2) });
|
|
84
84
|
}
|
|
85
|
-
|
|
85
|
+
for (const eventID of eventIDs) {
|
|
86
86
|
const subscriber = eventMap[eventName][eventID];
|
|
87
87
|
if (subscriber) {
|
|
88
88
|
subscriber.callback.call(subscriber.scope, param);
|
|
89
89
|
}
|
|
90
|
-
}
|
|
90
|
+
}
|
|
91
91
|
return this;
|
|
92
92
|
},
|
|
93
93
|
/**
|
|
@@ -113,7 +113,7 @@ const PubSubModule = {
|
|
|
113
113
|
* @param {String} eventName Name of the event to listen
|
|
114
114
|
* @param {Function} optionalCallback Callback function to call when event occur
|
|
115
115
|
* @param {Object} optionalScope
|
|
116
|
-
* @
|
|
116
|
+
* @returns {String} event identifier that should be used to unsubscribe
|
|
117
117
|
*/
|
|
118
118
|
subscribe(eventName, optionalCallback, optionalScope) {
|
|
119
119
|
if (!eventName) {
|
|
@@ -138,12 +138,12 @@ const PubSubModule = {
|
|
|
138
138
|
*/
|
|
139
139
|
unsubscribe(bindID) {
|
|
140
140
|
const IDs = Array.isArray(bindID) ? bindID : [bindID];
|
|
141
|
-
|
|
141
|
+
for (const id of IDs) {
|
|
142
142
|
const eventName = extractEventName(id);
|
|
143
143
|
if ((0, has_1.default)(eventMap, `${eventName}.${id}`)) {
|
|
144
144
|
delete eventMap[eventName][id];
|
|
145
145
|
}
|
|
146
|
-
}
|
|
146
|
+
}
|
|
147
147
|
},
|
|
148
148
|
};
|
|
149
149
|
exports.default = Utils.isWindowAvailable() && window.PubSub ? window.PubSub : PubSubModule;
|
|
@@ -1,71 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* PubSub instance used for the bindCacheClearingEvents method.
|
|
11
|
-
*
|
|
12
|
-
* Since Mobile and Web use different instances of PubSub, this is unfortunately necessary to subscribe to
|
|
13
|
-
* events in both code bases.
|
|
14
|
-
*/
|
|
15
|
-
PubSub: any;
|
|
16
|
-
/**
|
|
17
|
-
* Filters out actions we never want to display on web or mobile.
|
|
18
|
-
*
|
|
19
|
-
* @param {Object[]} historyItems
|
|
20
|
-
*
|
|
21
|
-
* @returns {Object[]}
|
|
22
|
-
*/
|
|
23
|
-
filterHiddenActions: (historyItems: Object[]) => Object[];
|
|
24
|
-
/**
|
|
25
|
-
* Merges history items into the cache and creates it if it doesn't yet exist.
|
|
26
|
-
*
|
|
27
|
-
* @param {Number} reportID
|
|
28
|
-
* @param {Object[]} newHistory
|
|
29
|
-
*/
|
|
30
|
-
mergeItems(reportID: number, newHistory: Object[]): void;
|
|
31
|
-
/**
|
|
32
|
-
* Merges history items into the cache and creates it if it doesn't yet exist.
|
|
33
|
-
*
|
|
34
|
-
* @param {Number} reportID
|
|
35
|
-
* @param {Object[]} newHistory
|
|
36
|
-
*/
|
|
37
|
-
mergeHistoryByTimestamp(reportID: number, newHistory: Object[]): void;
|
|
38
|
-
/**
|
|
39
|
-
* Merges history items by reportActionID into the cache and creates it if it doesn't yet exist.
|
|
40
|
-
*
|
|
41
|
-
* @param {Number} reportID
|
|
42
|
-
* @param {Object[]} newHistory
|
|
43
|
-
*/
|
|
44
|
-
mergeHistoryByReportActionID(reportID: number, newHistory: Object[]): void;
|
|
45
|
-
/**
|
|
46
|
-
* Gets the history.
|
|
47
|
-
*
|
|
48
|
-
* @param {Number} reportID
|
|
49
|
-
* @param {Boolean} ignoreCache
|
|
50
|
-
*
|
|
51
|
-
* @returns {Deferred}
|
|
52
|
-
*/
|
|
53
|
-
get(reportID: number, ignoreCache: boolean): Deferred;
|
|
54
|
-
/**
|
|
55
|
-
* Gets the history. This flow does not depend on the deprecated sequence number in report actions.
|
|
56
|
-
*
|
|
57
|
-
* @param {Number} reportID
|
|
58
|
-
* @param {Boolean} ignoreCache
|
|
59
|
-
*
|
|
60
|
-
* @returns {Deferred}
|
|
61
|
-
*/
|
|
62
|
-
getFlatHistory(reportID: number, ignoreCache: boolean): Deferred;
|
|
63
|
-
/**
|
|
64
|
-
* Gets the history from the cache if it exists. Otherwise fully loads the history.
|
|
65
|
-
*
|
|
66
|
-
* @param {Number} reportID
|
|
67
|
-
*
|
|
68
|
-
* @return {Deferrred}
|
|
69
|
-
*/
|
|
70
|
-
getFromCache(reportID: number): Deferrred;
|
|
71
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Creates a report history store with platform-specific API and PubSub implementations.
|
|
3
|
+
*
|
|
4
|
+
* @param {Object} API
|
|
5
|
+
* @param {Object} PubSub
|
|
6
|
+
* @returns {Object}
|
|
7
|
+
*/
|
|
8
|
+
export default function ReportHistoryStore(API: Object, PubSub: Object): Object;
|