@tesouro/embedded-components-react 0.4.4 → 0.4.6

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.
Files changed (69) hide show
  1. package/README.md +37 -37
  2. package/dist/index.d.ts +14 -8
  3. package/dist/lib/CreditCardsWidget.d.ts +4 -2
  4. package/dist/lib/DebitCardsWidget.d.ts +4 -2
  5. package/dist/lib/WidgetSuite.d.ts +14 -8
  6. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index.js +8 -8
  7. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index10.js +50 -29
  8. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index11.js +39 -30
  9. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index12.js +26 -311
  10. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index13.js +326 -12
  11. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index14.js +1 -1
  12. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index15.js +1 -1
  13. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index4.js +13 -27
  14. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index5.js +28 -245
  15. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index6.js +256 -92
  16. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index7.js +86 -73
  17. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index8.js +77 -14
  18. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index9.js +18 -63
  19. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index.js +4 -4
  20. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index10.js +1 -1
  21. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index14.js +1 -1
  22. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index22.js +1 -1
  23. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index29.js +1 -1
  24. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index3.js +1 -1
  25. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index30.js +1 -1
  26. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index31.js +1 -1
  27. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index32.js +2 -2
  28. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index33.js +1 -1
  29. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index35.js +1 -1
  30. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index37.js +72 -56
  31. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index38.js +77 -48
  32. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index39.js +47 -91
  33. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index40.js +91 -33
  34. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index41.js +33 -167
  35. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index42.js +168 -75
  36. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index43.js +75 -21
  37. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index44.js +23 -210
  38. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index45.js +199 -203
  39. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index46.js +198 -89
  40. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index47.js +105 -13
  41. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index48.js +12 -47
  42. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index49.js +47 -31
  43. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index50.js +27 -198
  44. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index51.js +198 -30
  45. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index52.js +30 -234
  46. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index53.js +240 -18
  47. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index54.js +19 -341
  48. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index55.js +344 -4
  49. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index56.js +4 -33
  50. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index57.js +32 -83
  51. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index58.js +25 -25
  52. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index59.js +1 -1
  53. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index65.js +1 -1
  54. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index7.js +1 -1
  55. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index76.js +1 -1
  56. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index77.js +2 -2
  57. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index9.js +1 -1
  58. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index25.js +2 -0
  59. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index26.js +28 -3
  60. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index56.js +2 -0
  61. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index57.js +152 -131
  62. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index97.js +1 -1
  63. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index98.js +32 -27
  64. package/dist/libs/tesouro-embedded-components-react/cards-widget/ui/dist/lib/CardsList/CardsList.js +84 -87
  65. package/dist/libs/tesouro-embedded-components-react/cards-widget/ui/dist/lib/CardsList/labels.js +0 -1
  66. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  67. package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/index4.js +2 -2
  68. package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/index9.js +12 -10
  69. package/package.json +1 -1
@@ -1,31 +1,17 @@
1
1
  import { organizationHeaders as e } from "../../../shared/data-access/dist/lib/organizationHeaders.js";
2
- import { getApprovalRequestsQueryKey as t, getPayablesAnalyticsQueryKey as n, getPayablesIdHistoryQueryKey as r, getPayablesIdLineItemsQueryKey as i, getPayablesIdQueryKey as a, getPayablesQueryKey as o, getPaymentRecordsQueryKey as s } from "../../../shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js";
2
+ import { getPayablesIdOptions as t } from "../../../shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js";
3
3
  import "../../../shared/data-access/dist/index.js";
4
4
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index4.js
5
- var c = ({ client: t, organizationId: n }) => o({
6
- client: t,
7
- headers: e(n)
8
- }), l = ({ client: n, organizationId: r }) => t({
9
- client: n,
10
- headers: e(r)
11
- }), u = ({ client: t, organizationId: r }) => n({
12
- client: t,
13
- headers: e(r)
14
- }), d = ({ client: t, organizationId: n, payableId: r }) => a({
15
- client: t,
16
- headers: e(n),
17
- path: { payable_id: r }
18
- }), f = ({ client: t, organizationId: n, payableId: i }) => r({
19
- client: t,
20
- headers: e(n),
21
- path: { payable_id: i }
22
- }), p = ({ client: t, organizationId: n, payableId: r }) => i({
23
- client: t,
24
- headers: e(n),
25
- path: { payable_id: r }
26
- }), m = ({ client: t, organizationId: n }) => s({
27
- client: t,
28
- headers: e(n)
29
- }), h = "payable", g = "desc";
5
+ var n = 2500;
6
+ function r({ client: n, organizationId: r, payableId: i }) {
7
+ return {
8
+ ...t({
9
+ client: n,
10
+ headers: e(r),
11
+ path: { payable_id: i }
12
+ }),
13
+ refetchInterval: (e) => e.state.data?.ocr_status === "processing" && 2500
14
+ };
15
+ }
30
16
  //#endregion
31
- export { g as NEWEST_REQUEST_FIRST, h as PAYABLE_OBJECT_TYPE, l as approvalRequestsInvalidationKey, f as payableHistoryInvalidationKey, d as payableInvalidationKey, p as payableLineItemsInvalidationKey, m as payablePaymentRecordsInvalidationKey, u as payablesAnalyticsInvalidationKey, c as payablesInvalidationKey };
17
+ export { n as OCR_POLL_INTERVAL_MS, r as payableOcrQueryOptions };
@@ -1,248 +1,31 @@
1
- import { cancelAllClients as e, invalidateAllClients as t, removeInactiveFromAllClients as n } from "../../../shared/data-access/dist/lib/clientRegistry.js";
2
- import { organizationHeaders as r } from "../../../shared/data-access/dist/lib/organizationHeaders.js";
3
- import { getApprovalRequests as i, getPayablesId as a, getPayablesIdHistory as o, getPaymentRecords as s } from "../../../shared/data-access/dist/lib/rest/sdk.gen.js";
1
+ import { organizationHeaders as e } from "../../../shared/data-access/dist/lib/organizationHeaders.js";
2
+ import { getApprovalRequestsQueryKey as t, getPayablesAnalyticsQueryKey as n, getPayablesIdHistoryQueryKey as r, getPayablesIdLineItemsQueryKey as i, getPayablesIdQueryKey as a, getPayablesQueryKey as o, getPaymentRecordsQueryKey as s } from "../../../shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js";
4
3
  import "../../../shared/data-access/dist/index.js";
5
- import { isLiveScheduledPaymentRecord as c } from "./index3.js";
6
- import { NEWEST_REQUEST_FIRST as l, PAYABLE_OBJECT_TYPE as u, approvalRequestsInvalidationKey as d, payableHistoryInvalidationKey as f, payableInvalidationKey as p, payableLineItemsInvalidationKey as m, payablePaymentRecordsInvalidationKey as h, payablesAnalyticsInvalidationKey as g, payablesInvalidationKey as _ } from "./index4.js";
7
4
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index5.js
8
- async function v({ client: e, organizationId: n, payableId: r, payableIds: i, deletedPayableIds: a, includeLineItems: o, includeApprovalRequests: s }) {
9
- let c = {
10
- client: e,
11
- organizationId: n
12
- }, l = new Set(a ?? []), u = [.../* @__PURE__ */ new Set([...i ?? [], r])].filter((e) => !!e && !l.has(e)).map((e) => ({
13
- ...c,
14
- payableId: e
15
- })), v = [
16
- _(c),
17
- g(c),
18
- ...s ? [d(c)] : [],
19
- ...u.flatMap((e) => [
20
- p(e),
21
- f(e),
22
- h(e),
23
- ...o ? [m(e)] : []
24
- ])
25
- ];
26
- await Promise.all(v.map((e) => t(e))), await Promise.all([...l].map((t) => y({
27
- client: e,
28
- organizationId: n,
29
- payableId: t
30
- })));
31
- }
32
- async function y({ client: t, organizationId: r, payableId: i }) {
33
- if (!i) return;
34
- let a = {
35
- client: t,
36
- organizationId: r,
37
- payableId: i
38
- }, o = [
39
- p(a),
40
- f(a),
41
- m(a)
42
- ];
43
- await Promise.all(o.map((t) => e(t))), o.forEach((e) => n(e));
44
- }
45
- async function b({ client: e, organizationId: n, payableId: r }) {
46
- let i = {
47
- client: e,
48
- organizationId: n
49
- };
50
- await Promise.all([t(_(i)), t(g(i))]), await y({
51
- client: e,
52
- organizationId: n,
53
- payableId: r
54
- });
55
- }
56
- var x = 2e4, S = 1e3, C = 1.5, w = 5e3, T = (e) => Math.min(e * C, w), E = /* @__PURE__ */ new Set(["new", "approve_in_progress"]), D = 6e4;
57
- async function O({ client: e, organizationId: n, payableId: r }) {
58
- await t(d({
59
- client: e,
60
- organizationId: n
61
- })), await v({
62
- client: e,
63
- organizationId: n,
64
- payableId: r
65
- });
66
- }
67
- var k = 100;
68
- async function A({ client: e, organizationId: t, payableId: n }) {
69
- try {
70
- let { data: a } = await i({
71
- client: e,
72
- headers: r(t),
73
- query: {
74
- object_id: n,
75
- object_type: u,
76
- order: l,
77
- limit: k
78
- }
79
- });
80
- return (a?.data ?? []).map((e) => `${e.id}:${e.status}`).sort().join(",");
81
- } catch {
82
- return;
83
- }
84
- }
85
- var j = 3, M = 250;
86
- async function N(e) {
87
- let t = 0;
88
- for (;;) {
89
- let n = await I(e);
90
- if (t += 1, n.readable || t >= j) return n;
91
- await new Promise((e) => {
92
- setTimeout(e, M * t);
93
- });
94
- }
95
- }
96
- var P = "submitted_for_approval", F = 100;
97
- async function I({ client: e, organizationId: t, payableId: n }) {
98
- try {
99
- let { data: i } = await o({
100
- client: e,
101
- headers: r(t),
102
- path: { payable_id: n },
103
- query: {
104
- sort: "timestamp",
105
- order: "asc",
106
- limit: F
107
- }
108
- });
109
- return {
110
- readable: !0,
111
- at: (i?.data ?? []).reduce((e, t) => t.event_type === P ? t.timestamp : e, void 0)
112
- };
113
- } catch {
114
- return { readable: !1 };
115
- }
116
- }
117
- async function L(e, { requireRoundMarker: t = !1 } = {}) {
118
- let [n, r] = await Promise.all([A(e), t ? N(e) : void 0]), i = n, a = async () => {
119
- if (!r?.readable) return !0;
120
- let t = await I(e);
121
- return t.readable && t.at !== r.at;
122
- }, o = !1;
123
- return { async poll() {
124
- let t = await A(e);
125
- return t !== void 0 && i === void 0 ? (i = t, o = !0, await a() ? "changed" : "resynced") : (t !== void 0 && t !== i && (o = !0), o && await a() ? "changed" : "unchanged");
126
- } };
127
- }
128
- async function R({ client: e, organizationId: t, payableId: n, watch: i }) {
129
- let o = Date.now() + D, s = S, c = !1;
130
- for (; !c && Date.now() < o;) {
131
- await new Promise((e) => {
132
- setTimeout(e, s);
133
- }), s = T(s);
134
- try {
135
- let { data: i } = await a({
136
- client: e,
137
- headers: r(t),
138
- path: { payable_id: n }
139
- });
140
- c = !!(i?.status && !E.has(i.status));
141
- } catch {}
142
- if (!c) {
143
- let r = await i.poll();
144
- c = r === "changed", r === "resynced" && await v({
145
- client: e,
146
- organizationId: t,
147
- payableId: n,
148
- includeApprovalRequests: !0
149
- });
150
- }
151
- }
152
- return await v({
153
- client: e,
154
- organizationId: t,
155
- payableId: n,
156
- includeApprovalRequests: !0
157
- }), c;
158
- }
159
- var z = 15e4, B = 3e3;
160
- async function V({ client: e, organizationId: t, payableId: n, watch: r }) {
161
- let i = Date.now() + z, a = B, o = !1;
162
- for (; !o && Date.now() < i;) {
163
- await new Promise((e) => {
164
- setTimeout(e, a);
165
- }), a = T(a);
166
- let i = await r.poll();
167
- o = i === "changed", i === "resynced" && await v({
168
- client: e,
169
- organizationId: t,
170
- payableId: n,
171
- includeApprovalRequests: !0
172
- });
173
- }
174
- return await v({
175
- client: e,
176
- organizationId: t,
177
- payableId: n,
178
- includeApprovalRequests: !0
179
- }), o;
180
- }
181
- var H = 100;
182
- async function U({ client: e, organizationId: t, payableId: n }) {
183
- let r = Date.now() + x, i = !1;
184
- for (; !i && Date.now() < r;) await new Promise((e) => {
185
- setTimeout(e, S);
186
- }), i = await W({
187
- client: e,
188
- organizationId: t,
189
- payableId: n
190
- }) === !0;
191
- return await v({
192
- client: e,
193
- organizationId: t,
194
- payableId: n
195
- }), i;
196
- }
197
- async function W({ client: e, organizationId: t, payableId: n }) {
198
- let i = /* @__PURE__ */ new Set(), a;
199
- try {
200
- do {
201
- let { data: o } = await s({
202
- client: e,
203
- headers: r(t),
204
- query: {
205
- limit: H,
206
- object_id__in: [n],
207
- order: "desc",
208
- sort: "paid_at",
209
- is_external: !1,
210
- ...a ? { pagination_token: a } : {}
211
- }
212
- });
213
- if ((o?.data ?? []).some(c)) return !0;
214
- let l = o?.next_pagination_token ?? void 0;
215
- a = l && !i.has(l) ? (i.add(l), l) : void 0;
216
- } while (a);
217
- return !1;
218
- } catch {
219
- return;
220
- }
221
- }
222
- async function G({ client: e, organizationId: t, payableId: n }) {
223
- let i = Date.now() + x, o = !1;
224
- for (; !o && Date.now() < i;) {
225
- await new Promise((e) => {
226
- setTimeout(e, S);
227
- });
228
- try {
229
- let { data: i } = await a({
230
- client: e,
231
- headers: r(t),
232
- path: { payable_id: n }
233
- });
234
- o = !i?.scheduled_payment_date && await W({
235
- client: e,
236
- organizationId: t,
237
- payableId: n
238
- }) === !1;
239
- } catch {}
240
- }
241
- return await v({
242
- client: e,
243
- organizationId: t,
244
- payableId: n
245
- }), o;
246
- }
5
+ var c = ({ client: t, organizationId: n }) => o({
6
+ client: t,
7
+ headers: e(n)
8
+ }), l = ({ client: n, organizationId: r }) => t({
9
+ client: n,
10
+ headers: e(r)
11
+ }), u = ({ client: t, organizationId: r }) => n({
12
+ client: t,
13
+ headers: e(r)
14
+ }), d = ({ client: t, organizationId: n, payableId: r }) => a({
15
+ client: t,
16
+ headers: e(n),
17
+ path: { payable_id: r }
18
+ }), f = ({ client: t, organizationId: n, payableId: i }) => r({
19
+ client: t,
20
+ headers: e(n),
21
+ path: { payable_id: i }
22
+ }), p = ({ client: t, organizationId: n, payableId: r }) => i({
23
+ client: t,
24
+ headers: e(n),
25
+ path: { payable_id: r }
26
+ }), m = ({ client: t, organizationId: n }) => s({
27
+ client: t,
28
+ headers: e(n)
29
+ }), h = "payable", g = "desc";
247
30
  //#endregion
248
- export { L as beginApprovalRequestWatch, O as invalidateApprovalDecisionQueries, b as invalidateDeletedPayableQueries, v as invalidatePayableQueries, R as reconcileApprovalDecisionQueries, G as reconcileCancelledPaymentQueries, U as reconcileScheduledPaymentQueries, V as reconcileSubmittedForApprovalQueries };
31
+ export { g as NEWEST_REQUEST_FIRST, h as PAYABLE_OBJECT_TYPE, l as approvalRequestsInvalidationKey, f as payableHistoryInvalidationKey, d as payableInvalidationKey, p as payableLineItemsInvalidationKey, m as payablePaymentRecordsInvalidationKey, u as payablesAnalyticsInvalidationKey, c as payablesInvalidationKey };
@@ -1,106 +1,270 @@
1
- "use client";
2
- "use client";
3
- "use client";
4
- "use client";
5
- import { useEmbedApi as e } from "../../../shared/data-access/dist/lib/EmbedApiContext.js";
6
- import { organizationHeaders as t } from "../../../shared/data-access/dist/lib/organizationHeaders.js";
7
- import { deletePayablesId as n, postPayablesIdCancel as r, postPayablesIdDuplicatesIdConfirm as i, postPayablesIdDuplicatesIdDismiss as a } from "../../../shared/data-access/dist/lib/rest/sdk.gen.js";
1
+ import { cancelAllClients as e, invalidateAllClients as t, removeInactiveFromAllClients as n } from "../../../shared/data-access/dist/lib/clientRegistry.js";
2
+ import { organizationHeaders as r } from "../../../shared/data-access/dist/lib/organizationHeaders.js";
3
+ import { getApprovalRequests as i, getPayablesId as a, getPayablesIdHistory as o, getPaymentRecords as s } from "../../../shared/data-access/dist/lib/rest/sdk.gen.js";
8
4
  import "../../../shared/data-access/dist/index.js";
9
- import { invalidatePayableQueries as o } from "./index5.js";
10
- import { useMutation as s } from "@tanstack/react-query";
5
+ import { isLiveScheduledPaymentRecord as c } from "./index3.js";
6
+ import { NEWEST_REQUEST_FIRST as l, PAYABLE_OBJECT_TYPE as u, approvalRequestsInvalidationKey as d, payableHistoryInvalidationKey as f, payableInvalidationKey as p, payableLineItemsInvalidationKey as m, payablePaymentRecordsInvalidationKey as h, payablesAnalyticsInvalidationKey as g, payablesInvalidationKey as _ } from "./index5.js";
7
+ import { OCR_POLL_INTERVAL_MS as v } from "./index4.js";
11
8
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/data-access/dist/index6.js
12
- var c = [
13
- "suspected",
14
- "dismissed",
15
- "confirmed"
16
- ];
17
- function l(e) {
18
- if (typeof e != "object" || !e) return !1;
19
- let t = e;
20
- return typeof t.id == "string" && typeof t.matched_payable_id == "string" && c.includes(t.status);
9
+ async function y({ client: e, organizationId: n, payableId: r, payableIds: i, deletedPayableIds: a, includeLineItems: o, includeApprovalRequests: s }) {
10
+ let c = {
11
+ client: e,
12
+ organizationId: n
13
+ }, l = new Set(a ?? []), u = [.../* @__PURE__ */ new Set([...i ?? [], r])].filter((e) => !!e && !l.has(e)).map((e) => ({
14
+ ...c,
15
+ payableId: e
16
+ })), v = [
17
+ _(c),
18
+ g(c),
19
+ ...s ? [d(c)] : [],
20
+ ...u.flatMap((e) => [
21
+ p(e),
22
+ f(e),
23
+ h(e),
24
+ ...o ? [m(e)] : []
25
+ ])
26
+ ];
27
+ await Promise.all(v.map((e) => t(e))), await Promise.all([...l].map((t) => b({
28
+ client: e,
29
+ organizationId: n,
30
+ payableId: t
31
+ })));
21
32
  }
22
- function u(e) {
23
- return Array.isArray(e?.duplicates) ? e.duplicates.filter(l) : [];
33
+ async function b({ client: t, organizationId: r, payableId: i }) {
34
+ if (!i) return;
35
+ let a = {
36
+ client: t,
37
+ organizationId: r,
38
+ payableId: i
39
+ }, o = [
40
+ p(a),
41
+ f(a),
42
+ m(a)
43
+ ];
44
+ await Promise.all(o.map((t) => e(t))), o.forEach((e) => n(e));
24
45
  }
25
- function d(e) {
26
- return u(e).filter((e) => e.status === "suspected");
46
+ async function x({ client: e, organizationId: n, payableId: r }) {
47
+ let i = {
48
+ client: e,
49
+ organizationId: n
50
+ };
51
+ await Promise.all([t(_(i)), t(g(i))]), await b({
52
+ client: e,
53
+ organizationId: n,
54
+ payableId: r
55
+ });
27
56
  }
28
- function f(e) {
29
- return d(e).length > 0;
57
+ var S = 2e4, C = 1e3, w = 1.5, T = 5e3, E = (e) => Math.min(e * w, T), D = /* @__PURE__ */ new Set(["new", "approve_in_progress"]), O = 6e4;
58
+ async function k({ client: e, organizationId: n, payableId: r }) {
59
+ await t(d({
60
+ client: e,
61
+ organizationId: n
62
+ })), await y({
63
+ client: e,
64
+ organizationId: n,
65
+ payableId: r
66
+ });
30
67
  }
31
- var p = {
32
- Keep: "keep",
33
- Remove: "remove"
34
- }, m = class extends Error {
35
- applied;
36
- constructor(e, t) {
37
- super("A duplicate verdict batch failed partway through.", { cause: t }), this.name = "DuplicateVerdictBatchError", this.applied = e;
68
+ var A = 100;
69
+ async function j({ client: e, organizationId: t, payableId: n }) {
70
+ try {
71
+ let { data: a } = await i({
72
+ client: e,
73
+ headers: r(t),
74
+ query: {
75
+ object_id: n,
76
+ object_type: u,
77
+ order: l,
78
+ limit: A
79
+ }
80
+ });
81
+ return (a?.data ?? []).map((e) => `${e.id}:${e.status}`).sort().join(",");
82
+ } catch {
83
+ return;
38
84
  }
39
- };
40
- function h(e) {
41
- return e.payableIds.length > 0 || e.deletedPayableIds.length > 0;
42
85
  }
43
- function g() {
44
- let { client: c, organizationId: l } = e();
45
- return s({
46
- mutationFn: async ({ verdict: e, targets: o }) => {
47
- let s = t(l), u = [], d = [], f = () => o.filter((e) => e.matchedPayableId !== void 0 && d.includes(e.payableId) && !d.includes(e.matchedPayableId)).map((e) => e.matchedPayableId), h = () => ({
48
- payableIds: [.../* @__PURE__ */ new Set([...u, ...f()])],
49
- deletedPayableIds: [...new Set(d)]
50
- });
51
- try {
52
- let t = /* @__PURE__ */ new Set();
53
- if (e === p.Remove) {
54
- for (let e of o) if (!t.has(e.payableId)) {
55
- if (t.add(e.payableId), e.removeBy === "delete") {
56
- await n({
57
- client: c,
58
- headers: s,
59
- path: { payable_id: e.payableId },
60
- throwOnError: !0
61
- }), d.push(e.payableId);
62
- continue;
63
- }
64
- e.removeBy === "cancel" && (await r({
65
- client: c,
66
- headers: s,
67
- path: { payable_id: e.payableId },
68
- throwOnError: !0
69
- }), u.push(e.payableId));
70
- }
71
- }
72
- let l = /* @__PURE__ */ new Set(), f = e === p.Remove ? i : a;
73
- for (let e of o) l.has(e.duplicateId) || d.includes(e.payableId) || e.matchedPayableId && d.includes(e.matchedPayableId) || (l.add(e.duplicateId), await f({
74
- client: c,
75
- headers: s,
76
- path: {
77
- payable_id: e.payableId,
78
- duplicate_id: e.duplicateId
79
- },
80
- throwOnError: !0
81
- }), u.push(e.payableId), e.matchedPayableId && u.push(e.matchedPayableId));
82
- } catch (e) {
83
- throw new m(h(), e);
86
+ var M = 3, N = 250;
87
+ async function P(e) {
88
+ let t = 0;
89
+ for (;;) {
90
+ let n = await L(e);
91
+ if (t += 1, n.readable || t >= M) return n;
92
+ await new Promise((e) => {
93
+ setTimeout(e, N * t);
94
+ });
95
+ }
96
+ }
97
+ var F = "submitted_for_approval", I = 100;
98
+ async function L({ client: e, organizationId: t, payableId: n }) {
99
+ try {
100
+ let { data: i } = await o({
101
+ client: e,
102
+ headers: r(t),
103
+ path: { payable_id: n },
104
+ query: {
105
+ sort: "timestamp",
106
+ order: "asc",
107
+ limit: I
84
108
  }
85
- return h();
86
- },
87
- onSuccess: async (e) => {
88
- await o({
89
- client: c,
90
- organizationId: l,
91
- payableIds: e.payableIds,
92
- deletedPayableIds: e.deletedPayableIds
109
+ });
110
+ return {
111
+ readable: !0,
112
+ at: (i?.data ?? []).reduce((e, t) => t.event_type === F ? t.timestamp : e, void 0)
113
+ };
114
+ } catch {
115
+ return { readable: !1 };
116
+ }
117
+ }
118
+ async function R(e, { requireRoundMarker: t = !1 } = {}) {
119
+ let [n, r] = await Promise.all([j(e), t ? P(e) : void 0]), i = n, a = async () => {
120
+ if (!r?.readable) return !0;
121
+ let t = await L(e);
122
+ return t.readable && t.at !== r.at;
123
+ }, o = !1;
124
+ return { async poll() {
125
+ let t = await j(e);
126
+ return t !== void 0 && i === void 0 ? (i = t, o = !0, await a() ? "changed" : "resynced") : (t !== void 0 && t !== i && (o = !0), o && await a() ? "changed" : "unchanged");
127
+ } };
128
+ }
129
+ async function z({ client: e, organizationId: t, payableId: n, watch: i }) {
130
+ let o = Date.now() + O, s = C, c = !1;
131
+ for (; !c && Date.now() < o;) {
132
+ await new Promise((e) => {
133
+ setTimeout(e, s);
134
+ }), s = E(s);
135
+ try {
136
+ let { data: i } = await a({
137
+ client: e,
138
+ headers: r(t),
139
+ path: { payable_id: n }
93
140
  });
94
- },
95
- onError: async (e) => {
96
- !(e instanceof m) || !h(e.applied) || await o({
97
- client: c,
98
- organizationId: l,
99
- payableIds: e.applied.payableIds,
100
- deletedPayableIds: e.applied.deletedPayableIds
141
+ c = !!(i?.status && !D.has(i.status));
142
+ } catch {}
143
+ if (!c) {
144
+ let r = await i.poll();
145
+ c = r === "changed", r === "resynced" && await y({
146
+ client: e,
147
+ organizationId: t,
148
+ payableId: n,
149
+ includeApprovalRequests: !0
101
150
  });
102
151
  }
103
- });
152
+ }
153
+ return await y({
154
+ client: e,
155
+ organizationId: t,
156
+ payableId: n,
157
+ includeApprovalRequests: !0
158
+ }), c;
159
+ }
160
+ var B = 15e4, V = 3e3;
161
+ async function H({ client: e, organizationId: t, payableId: n, watch: r }) {
162
+ let i = Date.now() + B, a = V, o = !1;
163
+ for (; !o && Date.now() < i;) {
164
+ await new Promise((e) => {
165
+ setTimeout(e, a);
166
+ }), a = E(a);
167
+ let i = await r.poll();
168
+ o = i === "changed", i === "resynced" && await y({
169
+ client: e,
170
+ organizationId: t,
171
+ payableId: n,
172
+ includeApprovalRequests: !0
173
+ });
174
+ }
175
+ return await y({
176
+ client: e,
177
+ organizationId: t,
178
+ payableId: n,
179
+ includeApprovalRequests: !0
180
+ }), o;
181
+ }
182
+ var U = 100;
183
+ async function W({ client: e, organizationId: t, payableId: n }) {
184
+ let r = Date.now() + S, i = !1;
185
+ for (; !i && Date.now() < r;) await new Promise((e) => {
186
+ setTimeout(e, C);
187
+ }), i = await G({
188
+ client: e,
189
+ organizationId: t,
190
+ payableId: n
191
+ }) === !0;
192
+ return await y({
193
+ client: e,
194
+ organizationId: t,
195
+ payableId: n
196
+ }), i;
197
+ }
198
+ async function G({ client: e, organizationId: t, payableId: n }) {
199
+ let i = /* @__PURE__ */ new Set(), a;
200
+ try {
201
+ do {
202
+ let { data: o } = await s({
203
+ client: e,
204
+ headers: r(t),
205
+ query: {
206
+ limit: U,
207
+ object_id__in: [n],
208
+ order: "desc",
209
+ sort: "paid_at",
210
+ is_external: !1,
211
+ ...a ? { pagination_token: a } : {}
212
+ }
213
+ });
214
+ if ((o?.data ?? []).some(c)) return !0;
215
+ let l = o?.next_pagination_token ?? void 0;
216
+ a = l && !i.has(l) ? (i.add(l), l) : void 0;
217
+ } while (a);
218
+ return !1;
219
+ } catch {
220
+ return;
221
+ }
222
+ }
223
+ async function K({ client: e, organizationId: t, payableId: n }) {
224
+ let i = Date.now() + S, o = !1;
225
+ for (; !o && Date.now() < i;) {
226
+ await new Promise((e) => {
227
+ setTimeout(e, C);
228
+ });
229
+ try {
230
+ let { data: i } = await a({
231
+ client: e,
232
+ headers: r(t),
233
+ path: { payable_id: n }
234
+ });
235
+ o = !i?.scheduled_payment_date && await G({
236
+ client: e,
237
+ organizationId: t,
238
+ payableId: n
239
+ }) === !1;
240
+ } catch {}
241
+ }
242
+ return await y({
243
+ client: e,
244
+ organizationId: t,
245
+ payableId: n
246
+ }), o;
247
+ }
248
+ async function q({ client: e, organizationId: t, payableId: n }) {
249
+ let i = Date.now() + S, o = !1;
250
+ for (; !o && Date.now() < i;) {
251
+ await new Promise((e) => {
252
+ setTimeout(e, v);
253
+ });
254
+ try {
255
+ let { data: i } = await a({
256
+ client: e,
257
+ headers: r(t),
258
+ path: { payable_id: n }
259
+ });
260
+ o = i?.ocr_status !== "processing";
261
+ } catch {}
262
+ }
263
+ return await y({
264
+ client: e,
265
+ organizationId: t,
266
+ payableId: n
267
+ }), o;
104
268
  }
105
269
  //#endregion
106
- export { p as DuplicateVerdict, m as DuplicateVerdictBatchError, f as hasSuspectedPayableDuplicate, u as readPayableDuplicates, d as suspectedPayableDuplicates, g as useApplyDuplicateVerdictsMutation };
270
+ export { R as beginApprovalRequestWatch, k as invalidateApprovalDecisionQueries, x as invalidateDeletedPayableQueries, y as invalidatePayableQueries, z as reconcileApprovalDecisionQueries, K as reconcileCancelledPaymentQueries, W as reconcileScheduledPaymentQueries, H as reconcileSubmittedForApprovalQueries, q as reconcileUploadedPayableOcr };