@zeniai/client-epic-state 5.2.10 → 5.2.11-beta0ND

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 (74) hide show
  1. package/lib/entity/invoicing/invoicingCommonPayload.d.ts +27 -29
  2. package/lib/entity/invoicing/invoicingCommonPayload.js +37 -75
  3. package/lib/entity/invoicing/product/productPayload.d.ts +10 -0
  4. package/lib/entity/invoicing/product/productPayload.js +14 -2
  5. package/lib/epic.d.ts +3 -2
  6. package/lib/epic.js +12 -5
  7. package/lib/esm/entity/invoicing/invoicingCommonPayload.js +33 -73
  8. package/lib/esm/entity/invoicing/product/productPayload.js +14 -2
  9. package/lib/esm/epic.js +8 -1
  10. package/lib/esm/index.js +7 -6
  11. package/lib/esm/view/companyMonthEndReportView/companyMonthEndReportViewReducer.js +6 -2
  12. package/lib/esm/view/companyMonthEndReportView/companyMonthEndReportViewState.js +4 -0
  13. package/lib/esm/view/companyMonthEndReportView/epics/saveCompanyMonthEndReportEpic.js +10 -6
  14. package/lib/esm/view/companyMonthEndReportView/epics/sendCompanyMonthEndReportEpic.js +9 -5
  15. package/lib/esm/view/companyMonthEndReportView/monthEndTemplateData.js +32 -0
  16. package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewPayload.js +25 -9
  17. package/lib/esm/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.js +6 -1
  18. package/lib/esm/view/invoicing/invoicingQboView/invoicingQboViewSelector.js +40 -0
  19. package/lib/esm/view/invoicing/settingsView/epics/connectInvoicingStripeEpic.js +27 -0
  20. package/lib/esm/view/invoicing/settingsView/epics/disconnectInvoicingStripeEpic.js +19 -0
  21. package/lib/esm/view/invoicing/settingsView/epics/fetchInvoicingSettingsEpic.js +19 -0
  22. package/lib/esm/view/invoicing/settingsView/epics/saveInvoicingSettingsEpic.js +39 -0
  23. package/lib/esm/view/invoicing/settingsView/epics/settingsViewActionType.js +1 -0
  24. package/lib/esm/view/invoicing/settingsView/epics/submitInvoicingQboSettingsEpic.js +25 -0
  25. package/lib/esm/view/invoicing/settingsView/invoicingQboSettingsFormConfig.js +48 -0
  26. package/lib/esm/view/invoicing/settingsView/settingsViewReducer.js +25 -1
  27. package/lib/esm/view/invoicing/settingsView/settingsViewSelector.js +41 -0
  28. package/lib/esm/view/recommendation/recommendationReducer.js +16 -1
  29. package/lib/esm/view/recommendation/submitRecommendationFeedbackEpic.js +52 -0
  30. package/lib/index.d.ts +12 -8
  31. package/lib/index.js +36 -28
  32. package/lib/view/companyMonthEndReportView/companyMonthEndReportViewPayload.d.ts +8 -0
  33. package/lib/view/companyMonthEndReportView/companyMonthEndReportViewReducer.d.ts +6 -2
  34. package/lib/view/companyMonthEndReportView/companyMonthEndReportViewReducer.js +6 -2
  35. package/lib/view/companyMonthEndReportView/companyMonthEndReportViewState.d.ts +2 -0
  36. package/lib/view/companyMonthEndReportView/companyMonthEndReportViewState.js +4 -0
  37. package/lib/view/companyMonthEndReportView/epics/saveCompanyMonthEndReportEpic.js +10 -6
  38. package/lib/view/companyMonthEndReportView/epics/sendCompanyMonthEndReportEpic.js +9 -5
  39. package/lib/view/companyMonthEndReportView/monthEndTemplateData.d.ts +16 -0
  40. package/lib/view/companyMonthEndReportView/monthEndTemplateData.js +36 -0
  41. package/lib/view/expenseAutomationView/types/reconciliationViewState.d.ts +1 -1
  42. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewPayload.d.ts +12 -1
  43. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/editInvoicingCatalogItemDetailViewPayload.js +25 -9
  44. package/lib/view/invoicing/editInvoicingCatalogItemDetailView/saveInvoicingCatalogItemEpic.js +6 -1
  45. package/lib/view/invoicing/invoicingQboView/invoicingQboViewSelector.d.ts +10 -1
  46. package/lib/view/invoicing/invoicingQboView/invoicingQboViewSelector.js +43 -1
  47. package/lib/view/invoicing/settingsView/epics/connectInvoicingStripeEpic.d.ts +6 -0
  48. package/lib/view/invoicing/settingsView/epics/connectInvoicingStripeEpic.js +31 -0
  49. package/lib/view/invoicing/settingsView/epics/disconnectInvoicingStripeEpic.d.ts +6 -0
  50. package/lib/view/invoicing/settingsView/epics/disconnectInvoicingStripeEpic.js +23 -0
  51. package/lib/view/invoicing/settingsView/epics/fetchInvoicingSettingsEpic.d.ts +6 -0
  52. package/lib/view/invoicing/settingsView/epics/fetchInvoicingSettingsEpic.js +23 -0
  53. package/lib/view/invoicing/settingsView/epics/saveInvoicingSettingsEpic.d.ts +6 -0
  54. package/lib/view/invoicing/settingsView/epics/saveInvoicingSettingsEpic.js +43 -0
  55. package/lib/view/invoicing/settingsView/epics/settingsViewActionType.d.ts +5 -0
  56. package/lib/view/invoicing/settingsView/epics/settingsViewActionType.js +2 -0
  57. package/lib/view/invoicing/settingsView/epics/submitInvoicingQboSettingsEpic.d.ts +11 -0
  58. package/lib/view/invoicing/settingsView/epics/submitInvoicingQboSettingsEpic.js +29 -0
  59. package/lib/view/invoicing/settingsView/invoicingQboSettingsFormConfig.d.ts +34 -0
  60. package/lib/view/invoicing/settingsView/invoicingQboSettingsFormConfig.js +53 -0
  61. package/lib/view/invoicing/settingsView/settingsViewReducer.d.ts +4 -1
  62. package/lib/view/invoicing/settingsView/settingsViewReducer.js +26 -2
  63. package/lib/view/invoicing/settingsView/settingsViewSelector.d.ts +35 -0
  64. package/lib/view/invoicing/settingsView/settingsViewSelector.js +43 -1
  65. package/lib/view/invoicing/settingsView/settingsViewState.d.ts +8 -0
  66. package/lib/view/recommendation/recommendationPayload.d.ts +34 -0
  67. package/lib/view/recommendation/recommendationReducer.d.ts +2 -1
  68. package/lib/view/recommendation/recommendationReducer.js +17 -2
  69. package/lib/view/recommendation/submitRecommendationFeedbackEpic.d.ts +7 -0
  70. package/lib/view/recommendation/submitRecommendationFeedbackEpic.js +56 -0
  71. package/package.json +1 -1
  72. package/lib/esm/view/invoicing/settingsView/settingsViewEpics.js +0 -92
  73. package/lib/view/invoicing/settingsView/settingsViewEpics.d.ts +0 -12
  74. package/lib/view/invoicing/settingsView/settingsViewEpics.js +0 -99
@@ -1,8 +1,12 @@
1
+ import { NestedAccountHierarchyForReport } from '../../../commonStateTypes/accountView/nestedAccountID';
1
2
  import { FetchState, FetchStateAndError } from '../../../commonStateTypes/common';
2
3
  import { InvoicingDunningActionOption, InvoicingNamedOption, InvoicingQboAccountMappingKindOption, InvoicingSettingsPayload } from '../../../entity/invoicing/invoicingCommonPayload';
3
4
  import { ZeniAPIStatus } from '../../../responsePayload';
4
5
  import { RootState } from '../../../rootStateTypes';
6
+ import { InvoicingQboConnection, InvoicingQboSyncHealth } from '../invoicingQboView/invoicingQboViewPayload';
7
+ import { InvoicingAccountingOption } from '../invoicingQboView/invoicingQboViewSelector';
5
8
  import { InvoicingBrandingFormLocalData } from './invoicingBrandingFormConfig';
9
+ import { InvoicingQboSettingsLocalData } from './invoicingQboSettingsFormConfig';
6
10
  /**
7
11
  * Shared primitive: the raw invoicing settings. Consumed internally by other
8
12
  * CES selectors (create-invoice, customer-detail, overview) and by non-settings
@@ -83,6 +87,37 @@ export interface InvoicingSettingsHubView {
83
87
  * and QBO slices read here are only fetched once a settings screen is mounted.
84
88
  */
85
89
  export declare const getInvoicingSettingsHubView: (state: RootState) => InvoicingSettingsHubView;
90
+ export interface InvoicingQboSettingsFormView {
91
+ accountMappingKindOptions: InvoicingQboAccountMappingKindOption[];
92
+ /** Accounts for the mapping dropdowns, narrowed per kind by the page. */
93
+ accounts: InvoicingAccountingOption[];
94
+ backfillState: FetchStateAndError;
95
+ /** So the screen can fetch only what is missing, without reading the slices. */
96
+ configFetchState: FetchState;
97
+ customerMatchingOptions: InvoicingNamedOption[];
98
+ isLoading: boolean;
99
+ /** The persisted sync toggle — the backfill guard checks that, not the draft. */
100
+ isSyncEnabledSaved: boolean;
101
+ /** The draft the page edits, seeded from the settings response. */
102
+ localData: InvoicingQboSettingsLocalData;
103
+ nestedAccountHierarchy: NestedAccountHierarchyForReport[];
104
+ retryFetchStateByTaskId: Record<string, FetchStateAndError>;
105
+ saveState: FetchStateAndError;
106
+ settingsFetchState: FetchState;
107
+ syncStatusOptions: InvoicingNamedOption[];
108
+ connection?: InvoicingQboConnection;
109
+ syncHealth?: InvoicingQboSyncHealth;
110
+ }
111
+ /**
112
+ * Bundled view for the QBO configuration page: the draft it edits, the accounts
113
+ * and option lists its dropdowns render, the connection and sync health it
114
+ * reports, and the fetch states that decide between skeleton, form and error.
115
+ *
116
+ * `localData` is the draft once the user has edited, and the settings response
117
+ * before that — so the page has one field to read and CES owns when it becomes
118
+ * available, rather than the page copying settings into local state.
119
+ */
120
+ export declare const getInvoicingQboSettingsFormView: (state: RootState) => InvoicingQboSettingsFormView;
86
121
  export interface InvoicingBrandingFormView {
87
122
  dateFormatOptions: InvoicingNamedOption[];
88
123
  localData: InvoicingBrandingFormLocalData;
@@ -1,11 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getInvoicingBrandingFormView = exports.getInvoicingSettingsHubView = exports.getInvoicingSettingsView = exports.getInvoicingSettingsFetchState = exports.getInvoicingSettings = void 0;
3
+ exports.getInvoicingBrandingFormView = exports.getInvoicingQboSettingsFormView = exports.getInvoicingSettingsHubView = exports.getInvoicingSettingsView = exports.getInvoicingSettingsFetchState = exports.getInvoicingSettings = void 0;
4
4
  exports.deriveInvoicingEnablePrerequisites = deriveInvoicingEnablePrerequisites;
5
5
  const invoicingCommonPayload_1 = require("../../../entity/invoicing/invoicingCommonPayload");
6
6
  const addressViewSelector_1 = require("../../addressView/addressViewSelector");
7
7
  const invoicingConfigViewSelector_1 = require("../invoicingConfigView/invoicingConfigViewSelector");
8
+ const invoicingQboViewSelector_1 = require("../invoicingQboView/invoicingQboViewSelector");
8
9
  const invoicingBrandingFormConfig_1 = require("./invoicingBrandingFormConfig");
10
+ const invoicingQboSettingsFormConfig_1 = require("./invoicingQboSettingsFormConfig");
9
11
  /**
10
12
  * Shared primitive: the raw invoicing settings. Consumed internally by other
11
13
  * CES selectors (create-invoice, customer-detail, overview) and by non-settings
@@ -100,6 +102,46 @@ const getInvoicingSettingsHubView = (state) => {
100
102
  };
101
103
  };
102
104
  exports.getInvoicingSettingsHubView = getInvoicingSettingsHubView;
105
+ /**
106
+ * Bundled view for the QBO configuration page: the draft it edits, the accounts
107
+ * and option lists its dropdowns render, the connection and sync health it
108
+ * reports, and the fetch states that decide between skeleton, form and error.
109
+ *
110
+ * `localData` is the draft once the user has edited, and the settings response
111
+ * before that — so the page has one field to read and CES owns when it becomes
112
+ * available, rather than the page copying settings into local state.
113
+ */
114
+ const getInvoicingQboSettingsFormView = (state) => {
115
+ const { error, fetchState, qboDraft, saveFetchState, settings } = state.invoicingSettingsViewState;
116
+ const { fetchState: configFetchState, qboAccountMappingKindOptions, qboCustomerMatchingOptions, qboSyncStatusOptions, } = (0, invoicingConfigViewSelector_1.getInvoicingConfigView)(state);
117
+ const qboView = (0, invoicingQboViewSelector_1.getInvoicingQboView)(state);
118
+ return {
119
+ accountMappingKindOptions: qboAccountMappingKindOptions,
120
+ accounts: qboView.accounts,
121
+ backfillState: qboView.backfillState,
122
+ connection: qboView.connection,
123
+ configFetchState,
124
+ customerMatchingOptions: qboCustomerMatchingOptions,
125
+ // The dropdowns cannot be built before both the settings and the accounts
126
+ // land, so the page waits on either rather than rendering empty pickers.
127
+ isLoading: fetchState === 'Not-Started' ||
128
+ fetchState === 'In-Progress' ||
129
+ (0, invoicingQboViewSelector_1.isInvoicingAccountingPickerDataLoading)(state),
130
+ isSyncEnabledSaved: settings?.qbo?.enabled === true,
131
+ // Seeded in the reducer when the settings response lands, so this is a plain
132
+ // read rather than a second place that decides what the page starts from.
133
+ localData: qboDraft ?? invoicingQboSettingsFormConfig_1.initialInvoicingQboSettingsLocalData,
134
+ nestedAccountHierarchy: qboView.nestedAccountHierarchy,
135
+ retryFetchStateByTaskId: qboView.retryFetchStateByTaskId,
136
+ saveState: saveFetchState.fetchState === 'Not-Started' && error != null
137
+ ? { fetchState, error }
138
+ : saveFetchState,
139
+ settingsFetchState: fetchState,
140
+ syncHealth: qboView.syncHealth,
141
+ syncStatusOptions: qboSyncStatusOptions,
142
+ };
143
+ };
144
+ exports.getInvoicingQboSettingsFormView = getInvoicingQboSettingsFormView;
103
145
  /**
104
146
  * Bundled view for the branding settings form: the draft `localData` (seeded
105
147
  * from the existing settings until the user edits), the business-address label
@@ -1,9 +1,17 @@
1
1
  import { FetchStateAndError, FetchedState } from '../../../commonStateTypes/common';
2
2
  import { InvoicingSettingsPayload } from '../../../entity/invoicing/invoicingCommonPayload';
3
3
  import { InvoicingBrandingFormLocalData } from './invoicingBrandingFormConfig';
4
+ import { InvoicingQboSettingsLocalData } from './invoicingQboSettingsFormConfig';
4
5
  export interface InvoicingSettingsViewState extends FetchedState {
5
6
  saveFetchState: FetchStateAndError;
6
7
  stripeFetchState: FetchStateAndError;
7
8
  brandingDraft?: InvoicingBrandingFormLocalData;
9
+ /**
10
+ * In-progress QBO settings edits. Held here rather than in the page so a
11
+ * selection cannot be lost between the change and the save, and so a
12
+ * half-finished edit survives navigating away. Undefined until first edited,
13
+ * which is what makes the server's settings the fallback.
14
+ */
15
+ qboDraft?: InvoicingQboSettingsLocalData;
8
16
  settings?: InvoicingSettingsPayload;
9
17
  }
@@ -12,4 +12,38 @@ interface FetchRecommendationPayloadWithCOT {
12
12
  recommendations: RecommendationPayloadWithCOT[];
13
13
  }
14
14
  export type FetchRecommendationResponseWithCOT = ZeniAPIResponse<FetchRecommendationPayloadWithCOT>;
15
+ export type RecommendationFeedbackDimension = 'vendor' | 'category' | 'class';
16
+ export type RecommendationFeedbackSource = 'primary' | 'alternate' | 'shadow' | 'qbo';
17
+ export type RecommendationFeedbackOutcome = 'accepted' | 'override_ranked' | 'override_outside' | 'retracted';
18
+ export interface RecommendationFeedbackValue {
19
+ name: string;
20
+ id?: string | null;
21
+ integrationId?: string | null;
22
+ }
23
+ export interface ShownRecommendationForFeedback {
24
+ rank: number;
25
+ source: RecommendationFeedbackSource;
26
+ value: RecommendationFeedbackValue;
27
+ confidence?: number | null;
28
+ cot?: string[];
29
+ reasoning?: string | null;
30
+ }
31
+ export interface SubmitRecommendationFeedbackPayload {
32
+ dimension: RecommendationFeedbackDimension;
33
+ outcome: RecommendationFeedbackOutcome;
34
+ selected: RecommendationFeedbackValue & {
35
+ isNewEntity?: boolean;
36
+ };
37
+ transactionId: string;
38
+ features?: Record<string, unknown> | null;
39
+ lineId?: string | null;
40
+ matchedRank?: number | null;
41
+ matchedSource?: RecommendationFeedbackSource | null;
42
+ reasonText?: string | null;
43
+ recommendationSetId?: string | null;
44
+ retractsFeedbackId?: string | null;
45
+ shownRecommendations?: ShownRecommendationForFeedback[];
46
+ skipped?: boolean;
47
+ topPickSource?: RecommendationFeedbackSource | null;
48
+ }
15
49
  export {};
@@ -5,6 +5,7 @@ import { TransactionID } from '../../entity/transaction/stateTypes/transactionID
5
5
  import { SupportedTransaction } from '../../entity/transaction/transactionState';
6
6
  import { ZeniAPIStatus } from '../../responsePayload';
7
7
  import { TransactionsTab } from '../expenseAutomationView/types/transactionsViewState';
8
+ import { SubmitRecommendationFeedbackPayload } from './recommendationPayload';
8
9
  import { EntityRecommendationState } from './recommendationState';
9
10
  export type RecommendationLineUpdateFlowType = 'categorization' | 'detail';
10
11
  type FetchEntityRecommendationsForLineUpdateCommonPayload = {
@@ -57,6 +58,6 @@ export declare const fetchEntityRecommendationsByTransactionId: import("@reduxjs
57
58
  }, "recommendation/updateRecommendationForEntityFailure">, indicateReadyToInitializeRecommendation: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[entityIdOrName: string, entityType: EntityType], {
58
59
  entityIdOrName: string;
59
60
  entityType: EntityType;
60
- }, "recommendation/indicateReadyToInitializeRecommendation", never, never>;
61
+ }, "recommendation/indicateReadyToInitializeRecommendation", never, never>, clearRecommendation: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"recommendation/clearRecommendation">, submitRecommendationFeedback: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[args: SubmitRecommendationFeedbackPayload], SubmitRecommendationFeedbackPayload, "recommendation/submitRecommendationFeedback", never, never>;
61
62
  declare const _default: import("redux").Reducer<EntityRecommendationState>;
62
63
  export default _default;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  var _a;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.indicateReadyToInitializeRecommendation = exports.updateRecommendationForEntityFailure = exports.updateRecommendationForEntity = exports.fetchRecommendationByEntityId = exports.fetchRecommendationByEntityName = exports.fetchEntityRecommendationsForLineUpdate = exports.fetchEntityRecommendationsByTransactionId = exports.initialState = void 0;
4
+ exports.submitRecommendationFeedback = exports.clearRecommendation = exports.indicateReadyToInitializeRecommendation = exports.updateRecommendationForEntityFailure = exports.updateRecommendationForEntity = exports.fetchRecommendationByEntityId = exports.fetchRecommendationByEntityName = exports.fetchEntityRecommendationsForLineUpdate = exports.fetchEntityRecommendationsByTransactionId = exports.initialState = void 0;
5
5
  const toolkit_1 = require("@reduxjs/toolkit");
6
6
  const rootActions_1 = require("../../rootActions");
7
7
  const recommendationState_1 = require("./recommendationState");
@@ -135,6 +135,21 @@ const recommendation = (0, toolkit_1.createSlice)({
135
135
  };
136
136
  },
137
137
  },
138
+ clearRecommendation(draft) {
139
+ Object.assign(draft, exports.initialState);
140
+ },
141
+ // Fire-and-forget human feedback on a recommendation (accept, ranked
142
+ // override or outside override). Handled by submitRecommendationFeedbackEpic
143
+ // which POSTs to the accounting recommendation-feedback endpoint. No state
144
+ // mutation: the categorization UX must not depend on the feedback round-trip.
145
+ submitRecommendationFeedback: {
146
+ reducer() {
147
+ // Fire-and-forget: no state mutation; the epic performs the POST.
148
+ },
149
+ prepare(args) {
150
+ return { payload: args };
151
+ },
152
+ },
138
153
  },
139
154
  extraReducers: (builder) => {
140
155
  builder.addCase(rootActions_1.clearAll, (draft) => {
@@ -142,7 +157,7 @@ const recommendation = (0, toolkit_1.createSlice)({
142
157
  });
143
158
  },
144
159
  });
145
- _a = recommendation.actions, exports.fetchEntityRecommendationsByTransactionId = _a.fetchEntityRecommendationsByTransactionId, exports.fetchEntityRecommendationsForLineUpdate = _a.fetchEntityRecommendationsForLineUpdate, exports.fetchRecommendationByEntityName = _a.fetchRecommendationByEntityName, exports.fetchRecommendationByEntityId = _a.fetchRecommendationByEntityId, exports.updateRecommendationForEntity = _a.updateRecommendationForEntity, exports.updateRecommendationForEntityFailure = _a.updateRecommendationForEntityFailure, exports.indicateReadyToInitializeRecommendation = _a.indicateReadyToInitializeRecommendation;
160
+ _a = recommendation.actions, exports.fetchEntityRecommendationsByTransactionId = _a.fetchEntityRecommendationsByTransactionId, exports.fetchEntityRecommendationsForLineUpdate = _a.fetchEntityRecommendationsForLineUpdate, exports.fetchRecommendationByEntityName = _a.fetchRecommendationByEntityName, exports.fetchRecommendationByEntityId = _a.fetchRecommendationByEntityId, exports.updateRecommendationForEntity = _a.updateRecommendationForEntity, exports.updateRecommendationForEntityFailure = _a.updateRecommendationForEntityFailure, exports.indicateReadyToInitializeRecommendation = _a.indicateReadyToInitializeRecommendation, exports.clearRecommendation = _a.clearRecommendation, exports.submitRecommendationFeedback = _a.submitRecommendationFeedback;
146
161
  exports.default = recommendation.reducer;
147
162
  const doUpdateRecommendationForEntity = (draft, entityId, entityType, payload) => {
148
163
  const key = (0, recommendationState_1.getEntityRecommendationKey)(entityType, entityId);
@@ -0,0 +1,7 @@
1
+ import { ActionsObservable, StateObservable } from 'redux-observable';
2
+ import { Observable } from 'rxjs';
3
+ import { RootState } from '../../reducer';
4
+ import { ZeniAPI } from '../../zeniAPI';
5
+ import { submitRecommendationFeedback } from './recommendationReducer';
6
+ export type ActionType = ReturnType<typeof submitRecommendationFeedback>;
7
+ export declare const submitRecommendationFeedbackEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.submitRecommendationFeedbackEpic = void 0;
4
+ const rxjs_1 = require("rxjs");
5
+ const operators_1 = require("rxjs/operators");
6
+ const responsePayload_1 = require("../../responsePayload");
7
+ const recommendationReducer_1 = require("./recommendationReducer");
8
+ const toRequestBody = (payload) => ({
9
+ line_id: payload.lineId ?? null,
10
+ dimension: payload.dimension,
11
+ recommendation_set_id: payload.recommendationSetId ?? null,
12
+ top_pick_source: payload.topPickSource ?? null,
13
+ shown_recommendations: (payload.shownRecommendations ?? []).map((recommendation) => ({
14
+ source: recommendation.source,
15
+ rank: recommendation.rank,
16
+ value: {
17
+ name: recommendation.value.name,
18
+ id: recommendation.value.id ?? null,
19
+ integration_id: recommendation.value.integrationId ?? null,
20
+ },
21
+ confidence: recommendation.confidence ?? null,
22
+ reasoning: recommendation.reasoning ?? null,
23
+ cot: recommendation.cot ?? [],
24
+ })),
25
+ selected: {
26
+ name: payload.selected.name,
27
+ id: payload.selected.id ?? null,
28
+ integration_id: payload.selected.integrationId ?? null,
29
+ is_new_entity: payload.selected.isNewEntity ?? false,
30
+ },
31
+ matched_source: payload.matchedSource ?? null,
32
+ matched_rank: payload.matchedRank ?? null,
33
+ outcome: payload.outcome,
34
+ reason_text: payload.reasonText ?? null,
35
+ skipped: payload.skipped ?? false,
36
+ retracts_feedback_id: payload.retractsFeedbackId ?? null,
37
+ features: payload.features ?? null,
38
+ });
39
+ // Fire-and-forget: the epic never re-emits an action. Feedback delivery is a
40
+ // side-effect that must not disrupt the categorization UX, so both the
41
+ // success and error paths complete silently (errors are logged for debugging).
42
+ const submitRecommendationFeedbackEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(recommendationReducer_1.submitRecommendationFeedback.match), (0, operators_1.mergeMap)((action) => {
43
+ const { transactionId } = action.payload;
44
+ return zeniAPI
45
+ .postAndGetJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/transactions/${transactionId}/recommendation-feedback`, toRequestBody(action.payload))
46
+ .pipe((0, operators_1.mergeMap)((response) => {
47
+ if (!(0, responsePayload_1.isSuccessStatus)(response)) {
48
+ console.error('submitRecommendationFeedbackEpic: recommendation feedback was not recorded', response.status);
49
+ }
50
+ return rxjs_1.EMPTY;
51
+ }), (0, operators_1.catchError)((error) => {
52
+ console.error('submitRecommendationFeedbackEpic: failed to submit recommendation feedback', error);
53
+ return rxjs_1.EMPTY;
54
+ }));
55
+ }));
56
+ exports.submitRecommendationFeedbackEpic = submitRecommendationFeedbackEpic;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "5.2.10",
3
+ "version": "5.2.11-beta0ND",
4
4
  "description": "Shared module between Web & Mobile containing required abstractions for state management, async network communication. ",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/esm/index.js",
@@ -1,92 +0,0 @@
1
- import { from, of } from 'rxjs';
2
- import { catchError, filter, mergeMap, switchMap } from 'rxjs/operators';
3
- import { updateAddresses } from '../../../entity/address/addressReducer';
4
- import { apiErrorSnackbarVariables } from '../../../entity/snackbar/snackbarApiError';
5
- import { openSnackbar } from '../../../entity/snackbar/snackbarReducer';
6
- import { createZeniAPIStatus, isSuccessResponse, } from '../../../responsePayload';
7
- import { connectInvoicingStripe, disconnectInvoicingStripe, fetchInvoicingSettings, invoicingStripeConnectionFailure, saveInvoicingSettings, saveInvoicingSettingsFailure, saveInvoicingSettingsSuccess, updateInvoicingSettings, updateInvoicingSettingsFailure, updateInvoicingStripeConnection, } from './settingsViewReducer';
8
- export const fetchInvoicingSettingsEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(fetchInvoicingSettings.match), switchMap(() => {
9
- const apiUrl = `${zeniAPI.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/settings`;
10
- return zeniAPI.getJSON(apiUrl).pipe(switchMap((response) => {
11
- if (isSuccessResponse(response) && response.data != null) {
12
- const address = response.data.address;
13
- return [
14
- ...(address != null ? [updateAddresses([address])] : []),
15
- updateInvoicingSettings(response.data),
16
- ];
17
- }
18
- return of(updateInvoicingSettingsFailure(response.status));
19
- }), catchError((error) => of(updateInvoicingSettingsFailure(createZeniAPIStatus('Unexpected Error', 'Fetch settings REST API call errored out ' +
20
- JSON.stringify(error))))));
21
- }));
22
- export const connectInvoicingStripeEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(connectInvoicingStripe.match), mergeMap((action) => {
23
- const apiUrl = `${zeniAPI.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/settings/stripe-connect/setup`;
24
- const { api_key, publishable_key, webhook_secret } = action.payload;
25
- const body = {
26
- api_key,
27
- publishable_key,
28
- ...(webhook_secret != null && webhook_secret !== ''
29
- ? { webhook_secret }
30
- : {}),
31
- };
32
- return zeniAPI
33
- .postAndGetJSON(apiUrl, body)
34
- .pipe(switchMap((response) => {
35
- if (isSuccessResponse(response) && response.data != null) {
36
- return of(updateInvoicingStripeConnection({
37
- stripe_connected: response.data.stripe_connected,
38
- publishable_key: response.data.publishable_key,
39
- }), fetchInvoicingSettings());
40
- }
41
- return of(invoicingStripeConnectionFailure(response.status));
42
- }), catchError((error) => of(invoicingStripeConnectionFailure(createZeniAPIStatus('Unexpected Error', 'Stripe connect setup REST API call errored out ' +
43
- JSON.stringify(error))))));
44
- }));
45
- export const disconnectInvoicingStripeEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(disconnectInvoicingStripe.match), mergeMap(() => {
46
- const apiUrl = `${zeniAPI.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/settings/stripe-connect/callback`;
47
- return zeniAPI
48
- .deleteAndGetJSON(apiUrl)
49
- .pipe(switchMap((response) => {
50
- if (isSuccessResponse(response)) {
51
- return of(updateInvoicingStripeConnection({
52
- stripe_connected: false,
53
- publishable_key: '',
54
- }), fetchInvoicingSettings());
55
- }
56
- return of(invoicingStripeConnectionFailure(response.status));
57
- }), catchError((error) => of(invoicingStripeConnectionFailure(createZeniAPIStatus('Unexpected Error', 'Stripe disconnect REST API call errored out ' +
58
- JSON.stringify(error))))));
59
- }));
60
- export const saveInvoicingSettingsEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(saveInvoicingSettings.match), mergeMap((action) => {
61
- const apiUrl = `${zeniAPI.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/settings`;
62
- const { settings, snackbarSection } = action.payload;
63
- /** `status` surfaces the platform's error text; omit it to keep the generic copy. */
64
- const snackbar = (messageText, status) => snackbarSection == null
65
- ? []
66
- : [
67
- openSnackbar({
68
- messageSection: snackbarSection,
69
- messageText,
70
- type: messageText === 'success' ? 'success' : 'error',
71
- variables: apiErrorSnackbarVariables(status),
72
- }),
73
- ];
74
- return zeniAPI
75
- .putAndGetJSON(apiUrl, { ...settings })
76
- .pipe(switchMap((response) => {
77
- if (isSuccessResponse(response) && response.data != null) {
78
- return from([
79
- saveInvoicingSettingsSuccess(response.data),
80
- ...snackbar('success'),
81
- ]);
82
- }
83
- return from([
84
- saveInvoicingSettingsFailure(response.status),
85
- ...snackbar('failed', response.status),
86
- ]);
87
- }), catchError((error) => from([
88
- saveInvoicingSettingsFailure(createZeniAPIStatus('Unexpected Error', 'Save settings REST API call errored out ' +
89
- JSON.stringify(error))),
90
- ...snackbar('failed'),
91
- ])));
92
- }));
@@ -1,12 +0,0 @@
1
- import { ActionsObservable, StateObservable } from 'redux-observable';
2
- import { Observable } from 'rxjs';
3
- import { updateAddresses } from '../../../entity/address/addressReducer';
4
- import { openSnackbar } from '../../../entity/snackbar/snackbarReducer';
5
- import { RootState } from '../../../rootStateTypes';
6
- import { ZeniAPI } from '../../../zeniAPI';
7
- import { connectInvoicingStripe, disconnectInvoicingStripe, fetchInvoicingSettings, invoicingStripeConnectionFailure, saveInvoicingSettings, saveInvoicingSettingsFailure, saveInvoicingSettingsSuccess, updateInvoicingSettings, updateInvoicingSettingsFailure, updateInvoicingStripeConnection } from './settingsViewReducer';
8
- export type ActionType = ReturnType<typeof fetchInvoicingSettings> | ReturnType<typeof updateInvoicingSettings> | ReturnType<typeof updateInvoicingSettingsFailure> | ReturnType<typeof saveInvoicingSettings> | ReturnType<typeof saveInvoicingSettingsSuccess> | ReturnType<typeof saveInvoicingSettingsFailure> | ReturnType<typeof connectInvoicingStripe> | ReturnType<typeof disconnectInvoicingStripe> | ReturnType<typeof updateInvoicingStripeConnection> | ReturnType<typeof invoicingStripeConnectionFailure> | ReturnType<typeof updateAddresses> | ReturnType<typeof openSnackbar>;
9
- export declare const fetchInvoicingSettingsEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
10
- export declare const connectInvoicingStripeEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
11
- export declare const disconnectInvoicingStripeEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
12
- export declare const saveInvoicingSettingsEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -1,99 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.saveInvoicingSettingsEpic = exports.disconnectInvoicingStripeEpic = exports.connectInvoicingStripeEpic = exports.fetchInvoicingSettingsEpic = void 0;
4
- const rxjs_1 = require("rxjs");
5
- const operators_1 = require("rxjs/operators");
6
- const addressReducer_1 = require("../../../entity/address/addressReducer");
7
- const snackbarApiError_1 = require("../../../entity/snackbar/snackbarApiError");
8
- const snackbarReducer_1 = require("../../../entity/snackbar/snackbarReducer");
9
- const responsePayload_1 = require("../../../responsePayload");
10
- const settingsViewReducer_1 = require("./settingsViewReducer");
11
- const fetchInvoicingSettingsEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(settingsViewReducer_1.fetchInvoicingSettings.match), (0, operators_1.switchMap)(() => {
12
- const apiUrl = `${zeniAPI.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/settings`;
13
- return zeniAPI.getJSON(apiUrl).pipe((0, operators_1.switchMap)((response) => {
14
- if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
15
- const address = response.data.address;
16
- return [
17
- ...(address != null ? [(0, addressReducer_1.updateAddresses)([address])] : []),
18
- (0, settingsViewReducer_1.updateInvoicingSettings)(response.data),
19
- ];
20
- }
21
- return (0, rxjs_1.of)((0, settingsViewReducer_1.updateInvoicingSettingsFailure)(response.status));
22
- }), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, settingsViewReducer_1.updateInvoicingSettingsFailure)((0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Fetch settings REST API call errored out ' +
23
- JSON.stringify(error))))));
24
- }));
25
- exports.fetchInvoicingSettingsEpic = fetchInvoicingSettingsEpic;
26
- const connectInvoicingStripeEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(settingsViewReducer_1.connectInvoicingStripe.match), (0, operators_1.mergeMap)((action) => {
27
- const apiUrl = `${zeniAPI.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/settings/stripe-connect/setup`;
28
- const { api_key, publishable_key, webhook_secret } = action.payload;
29
- const body = {
30
- api_key,
31
- publishable_key,
32
- ...(webhook_secret != null && webhook_secret !== ''
33
- ? { webhook_secret }
34
- : {}),
35
- };
36
- return zeniAPI
37
- .postAndGetJSON(apiUrl, body)
38
- .pipe((0, operators_1.switchMap)((response) => {
39
- if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
40
- return (0, rxjs_1.of)((0, settingsViewReducer_1.updateInvoicingStripeConnection)({
41
- stripe_connected: response.data.stripe_connected,
42
- publishable_key: response.data.publishable_key,
43
- }), (0, settingsViewReducer_1.fetchInvoicingSettings)());
44
- }
45
- return (0, rxjs_1.of)((0, settingsViewReducer_1.invoicingStripeConnectionFailure)(response.status));
46
- }), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, settingsViewReducer_1.invoicingStripeConnectionFailure)((0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Stripe connect setup REST API call errored out ' +
47
- JSON.stringify(error))))));
48
- }));
49
- exports.connectInvoicingStripeEpic = connectInvoicingStripeEpic;
50
- const disconnectInvoicingStripeEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(settingsViewReducer_1.disconnectInvoicingStripe.match), (0, operators_1.mergeMap)(() => {
51
- const apiUrl = `${zeniAPI.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/settings/stripe-connect/callback`;
52
- return zeniAPI
53
- .deleteAndGetJSON(apiUrl)
54
- .pipe((0, operators_1.switchMap)((response) => {
55
- if ((0, responsePayload_1.isSuccessResponse)(response)) {
56
- return (0, rxjs_1.of)((0, settingsViewReducer_1.updateInvoicingStripeConnection)({
57
- stripe_connected: false,
58
- publishable_key: '',
59
- }), (0, settingsViewReducer_1.fetchInvoicingSettings)());
60
- }
61
- return (0, rxjs_1.of)((0, settingsViewReducer_1.invoicingStripeConnectionFailure)(response.status));
62
- }), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, settingsViewReducer_1.invoicingStripeConnectionFailure)((0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Stripe disconnect REST API call errored out ' +
63
- JSON.stringify(error))))));
64
- }));
65
- exports.disconnectInvoicingStripeEpic = disconnectInvoicingStripeEpic;
66
- const saveInvoicingSettingsEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(settingsViewReducer_1.saveInvoicingSettings.match), (0, operators_1.mergeMap)((action) => {
67
- const apiUrl = `${zeniAPI.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/settings`;
68
- const { settings, snackbarSection } = action.payload;
69
- /** `status` surfaces the platform's error text; omit it to keep the generic copy. */
70
- const snackbar = (messageText, status) => snackbarSection == null
71
- ? []
72
- : [
73
- (0, snackbarReducer_1.openSnackbar)({
74
- messageSection: snackbarSection,
75
- messageText,
76
- type: messageText === 'success' ? 'success' : 'error',
77
- variables: (0, snackbarApiError_1.apiErrorSnackbarVariables)(status),
78
- }),
79
- ];
80
- return zeniAPI
81
- .putAndGetJSON(apiUrl, { ...settings })
82
- .pipe((0, operators_1.switchMap)((response) => {
83
- if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
84
- return (0, rxjs_1.from)([
85
- (0, settingsViewReducer_1.saveInvoicingSettingsSuccess)(response.data),
86
- ...snackbar('success'),
87
- ]);
88
- }
89
- return (0, rxjs_1.from)([
90
- (0, settingsViewReducer_1.saveInvoicingSettingsFailure)(response.status),
91
- ...snackbar('failed', response.status),
92
- ]);
93
- }), (0, operators_1.catchError)((error) => (0, rxjs_1.from)([
94
- (0, settingsViewReducer_1.saveInvoicingSettingsFailure)((0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Save settings REST API call errored out ' +
95
- JSON.stringify(error))),
96
- ...snackbar('failed'),
97
- ])));
98
- }));
99
- exports.saveInvoicingSettingsEpic = saveInvoicingSettingsEpic;