expensify-common 2.0.196 → 2.0.198

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/CONST.d.ts CHANGED
@@ -796,6 +796,9 @@ declare const CONST: {
796
796
  readonly VALIDATE_ACCOUNT: "validate_account";
797
797
  readonly REVEAL_CARD_DETAILS: "reveal_card_details";
798
798
  readonly REGISTER_AUTHENTICATION_KEY: "register_authentication_key";
799
+ readonly REPLACE_CARD: "replace_card";
800
+ readonly SHIP_CARD: "ship_card";
801
+ readonly REPORT_CARD_FRAUD: "report_card_fraud";
799
802
  };
800
803
  readonly EXPENSIFY_CARD: {
801
804
  readonly FEED_NAME: "Expensify Card";
package/dist/CONST.js CHANGED
@@ -839,6 +839,9 @@ const CONST = {
839
839
  VALIDATE_ACCOUNT: 'validate_account',
840
840
  REVEAL_CARD_DETAILS: 'reveal_card_details',
841
841
  REGISTER_AUTHENTICATION_KEY: 'register_authentication_key',
842
+ REPLACE_CARD: 'replace_card',
843
+ SHIP_CARD: 'ship_card',
844
+ REPORT_CARD_FRAUD: 'report_card_fraud',
842
845
  },
843
846
  EXPENSIFY_CARD: {
844
847
  FEED_NAME: 'Expensify Card',
@@ -25,24 +25,6 @@ function ReportHistoryStore(API, PubSub) {
25
25
  * @returns {Object[]}
26
26
  */
27
27
  const filterHiddenActions = (historyItems) => historyItems.filter((historyItem) => historyItem.shouldShow);
28
- /**
29
- * Merges history items into the cache and creates it if it doesn't yet exist.
30
- *
31
- * @param {Number} reportID
32
- * @param {Object[]} newHistory
33
- */
34
- function mergeItems(reportID, newHistory) {
35
- if (newHistory.length === 0) {
36
- return;
37
- }
38
- const newCache = newHistory.reverse().reduce((prev, curr) => {
39
- if (!prev.some((item) => item.sequenceNumber === curr.sequenceNumber)) {
40
- prev.unshift(curr);
41
- }
42
- return prev;
43
- }, store.cache[reportID] || []);
44
- store.cache[reportID] = newCache.sort((a, b) => b.sequenceNumber - a.sequenceNumber);
45
- }
46
28
  /**
47
29
  * Merges history items into the cache and creates it if it doesn't yet exist.
48
30
  *
@@ -80,51 +62,38 @@ function ReportHistoryStore(API, PubSub) {
80
62
  store.cache[reportID] = newCache.sort((a, b) => b.reportActionTimestamp - a.reportActionTimestamp);
81
63
  }
82
64
  /**
83
- * Gets the history.
65
+ * Gets the history. This flow does not depend on the deprecated sequence number in report actions.
84
66
  *
85
67
  * @param {Number} reportID
86
68
  * @param {Boolean} ignoreCache
87
69
  * @returns {Deferred}
88
70
  */
89
- function get(reportID, ignoreCache) {
71
+ function getFlatHistory(reportID, ignoreCache) {
90
72
  const promise = new simply_deferred_1.Deferred();
91
73
  if (ignoreCache) {
92
74
  delete store.cache[reportID];
93
75
  }
94
- const cachedHistory = store.cache[reportID] || [];
95
- const firstHistoryItem = cachedHistory[0] || {};
96
76
  store.API.Report_GetHistory({
97
77
  reportID,
98
- offset: firstHistoryItem.sequenceNumber || 0,
99
78
  })
100
79
  .done((recentHistory) => {
101
- mergeItems(reportID, recentHistory);
80
+ mergeHistoryByReportActionID(reportID, recentHistory);
102
81
  promise.resolve(store.cache[reportID]);
103
82
  })
104
83
  .fail(promise.reject);
105
84
  return promise;
106
85
  }
107
86
  /**
108
- * Gets the history. This flow does not depend on the deprecated sequence number in report actions.
87
+ * Gets the history.
88
+ *
89
+ * @deprecated use getFlatHistory instead.
109
90
  *
110
91
  * @param {Number} reportID
111
92
  * @param {Boolean} ignoreCache
112
93
  * @returns {Deferred}
113
94
  */
114
- function getFlatHistory(reportID, ignoreCache) {
115
- const promise = new simply_deferred_1.Deferred();
116
- if (ignoreCache) {
117
- delete store.cache[reportID];
118
- }
119
- store.API.Report_GetHistory({
120
- reportID,
121
- })
122
- .done((recentHistory) => {
123
- mergeHistoryByReportActionID(reportID, recentHistory);
124
- promise.resolve(store.cache[reportID]);
125
- })
126
- .fail(promise.reject);
127
- return promise;
95
+ function get(reportID, ignoreCache) {
96
+ return getFlatHistory(reportID, ignoreCache);
128
97
  }
129
98
  /**
130
99
  * Gets the history from the cache if it exists. Otherwise fully loads the history.
@@ -141,6 +110,15 @@ function ReportHistoryStore(API, PubSub) {
141
110
  return promise.resolve(cachedHistory);
142
111
  }
143
112
  return {
113
+ /**
114
+ * Gets the history.
115
+ *
116
+ * @deprecated use getFlatHistory instead.
117
+ *
118
+ * @param {Number} reportID
119
+ * @param {Boolean} ignoreCache
120
+ * @returns {Deferred}
121
+ */
144
122
  get: (reportID, ignoreCache = false) => {
145
123
  const promise = new simply_deferred_1.Deferred();
146
124
  get(reportID, ignoreCache)
@@ -159,22 +137,6 @@ function ReportHistoryStore(API, PubSub) {
159
137
  .fail(promise.reject);
160
138
  return promise;
161
139
  },
162
- insertIntoCache: (reportID, reportAction) => {
163
- const promise = new simply_deferred_1.Deferred();
164
- getFromCache(reportID)
165
- .done((cachedHistory) => {
166
- const sequenceNumber = reportAction.sequenceNumber;
167
- if (cachedHistory.length >= sequenceNumber) {
168
- mergeItems(reportID, [reportAction]);
169
- return promise.resolve(filterHiddenActions(store.cache[reportID]));
170
- }
171
- get(reportID)
172
- .done((reportHistory) => promise.resolve(filterHiddenActions(reportHistory)))
173
- .fail(promise.reject);
174
- })
175
- .fail(promise.reject);
176
- return promise;
177
- },
178
140
  insertIntoCacheByActionID: (reportID, reportAction) => {
179
141
  const promise = new simply_deferred_1.Deferred();
180
142
  getFromCache(reportID)
@@ -796,6 +796,9 @@ declare const CONST: {
796
796
  readonly VALIDATE_ACCOUNT: "validate_account";
797
797
  readonly REVEAL_CARD_DETAILS: "reveal_card_details";
798
798
  readonly REGISTER_AUTHENTICATION_KEY: "register_authentication_key";
799
+ readonly REPLACE_CARD: "replace_card";
800
+ readonly SHIP_CARD: "ship_card";
801
+ readonly REPORT_CARD_FRAUD: "report_card_fraud";
799
802
  };
800
803
  readonly EXPENSIFY_CARD: {
801
804
  readonly FEED_NAME: "Expensify Card";
package/dist/esm/CONST.js CHANGED
@@ -834,6 +834,9 @@ const CONST = {
834
834
  VALIDATE_ACCOUNT: 'validate_account',
835
835
  REVEAL_CARD_DETAILS: 'reveal_card_details',
836
836
  REGISTER_AUTHENTICATION_KEY: 'register_authentication_key',
837
+ REPLACE_CARD: 'replace_card',
838
+ SHIP_CARD: 'ship_card',
839
+ REPORT_CARD_FRAUD: 'report_card_fraud',
837
840
  },
838
841
  EXPENSIFY_CARD: {
839
842
  FEED_NAME: 'Expensify Card',
@@ -22,24 +22,6 @@ export default function ReportHistoryStore(API, PubSub) {
22
22
  * @returns {Object[]}
23
23
  */
24
24
  const filterHiddenActions = (historyItems) => historyItems.filter((historyItem) => historyItem.shouldShow);
25
- /**
26
- * Merges history items into the cache and creates it if it doesn't yet exist.
27
- *
28
- * @param {Number} reportID
29
- * @param {Object[]} newHistory
30
- */
31
- function mergeItems(reportID, newHistory) {
32
- if (newHistory.length === 0) {
33
- return;
34
- }
35
- const newCache = newHistory.reverse().reduce((prev, curr) => {
36
- if (!prev.some((item) => item.sequenceNumber === curr.sequenceNumber)) {
37
- prev.unshift(curr);
38
- }
39
- return prev;
40
- }, store.cache[reportID] || []);
41
- store.cache[reportID] = newCache.sort((a, b) => b.sequenceNumber - a.sequenceNumber);
42
- }
43
25
  /**
44
26
  * Merges history items into the cache and creates it if it doesn't yet exist.
45
27
  *
@@ -77,51 +59,38 @@ export default function ReportHistoryStore(API, PubSub) {
77
59
  store.cache[reportID] = newCache.sort((a, b) => b.reportActionTimestamp - a.reportActionTimestamp);
78
60
  }
79
61
  /**
80
- * Gets the history.
62
+ * Gets the history. This flow does not depend on the deprecated sequence number in report actions.
81
63
  *
82
64
  * @param {Number} reportID
83
65
  * @param {Boolean} ignoreCache
84
66
  * @returns {Deferred}
85
67
  */
86
- function get(reportID, ignoreCache) {
68
+ function getFlatHistory(reportID, ignoreCache) {
87
69
  const promise = new Deferred();
88
70
  if (ignoreCache) {
89
71
  delete store.cache[reportID];
90
72
  }
91
- const cachedHistory = store.cache[reportID] || [];
92
- const firstHistoryItem = cachedHistory[0] || {};
93
73
  store.API.Report_GetHistory({
94
74
  reportID,
95
- offset: firstHistoryItem.sequenceNumber || 0,
96
75
  })
97
76
  .done((recentHistory) => {
98
- mergeItems(reportID, recentHistory);
77
+ mergeHistoryByReportActionID(reportID, recentHistory);
99
78
  promise.resolve(store.cache[reportID]);
100
79
  })
101
80
  .fail(promise.reject);
102
81
  return promise;
103
82
  }
104
83
  /**
105
- * Gets the history. This flow does not depend on the deprecated sequence number in report actions.
84
+ * Gets the history.
85
+ *
86
+ * @deprecated use getFlatHistory instead.
106
87
  *
107
88
  * @param {Number} reportID
108
89
  * @param {Boolean} ignoreCache
109
90
  * @returns {Deferred}
110
91
  */
111
- function getFlatHistory(reportID, ignoreCache) {
112
- const promise = new Deferred();
113
- if (ignoreCache) {
114
- delete store.cache[reportID];
115
- }
116
- store.API.Report_GetHistory({
117
- reportID,
118
- })
119
- .done((recentHistory) => {
120
- mergeHistoryByReportActionID(reportID, recentHistory);
121
- promise.resolve(store.cache[reportID]);
122
- })
123
- .fail(promise.reject);
124
- return promise;
92
+ function get(reportID, ignoreCache) {
93
+ return getFlatHistory(reportID, ignoreCache);
125
94
  }
126
95
  /**
127
96
  * Gets the history from the cache if it exists. Otherwise fully loads the history.
@@ -138,6 +107,15 @@ export default function ReportHistoryStore(API, PubSub) {
138
107
  return promise.resolve(cachedHistory);
139
108
  }
140
109
  return {
110
+ /**
111
+ * Gets the history.
112
+ *
113
+ * @deprecated use getFlatHistory instead.
114
+ *
115
+ * @param {Number} reportID
116
+ * @param {Boolean} ignoreCache
117
+ * @returns {Deferred}
118
+ */
141
119
  get: (reportID, ignoreCache = false) => {
142
120
  const promise = new Deferred();
143
121
  get(reportID, ignoreCache)
@@ -156,22 +134,6 @@ export default function ReportHistoryStore(API, PubSub) {
156
134
  .fail(promise.reject);
157
135
  return promise;
158
136
  },
159
- insertIntoCache: (reportID, reportAction) => {
160
- const promise = new Deferred();
161
- getFromCache(reportID)
162
- .done((cachedHistory) => {
163
- const sequenceNumber = reportAction.sequenceNumber;
164
- if (cachedHistory.length >= sequenceNumber) {
165
- mergeItems(reportID, [reportAction]);
166
- return promise.resolve(filterHiddenActions(store.cache[reportID]));
167
- }
168
- get(reportID)
169
- .done((reportHistory) => promise.resolve(filterHiddenActions(reportHistory)))
170
- .fail(promise.reject);
171
- })
172
- .fail(promise.reject);
173
- return promise;
174
- },
175
137
  insertIntoCacheByActionID: (reportID, reportAction) => {
176
138
  const promise = new Deferred();
177
139
  getFromCache(reportID)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expensify-common",
3
- "version": "2.0.196",
3
+ "version": "2.0.198",
4
4
  "author": "Expensify, Inc.",
5
5
  "description": "Expensify libraries and components shared across different repos",
6
6
  "homepage": "https://expensify.com",