@zeniai/client-epic-state 4.19.84-betaVR4 → 4.19.84-betaVR5

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.
@@ -9,6 +9,7 @@ const transactionReducer_1 = require("../../../../entity/transaction/transaction
9
9
  const responsePayload_1 = require("../../../../responsePayload");
10
10
  const missingReceiptsPayload_1 = require("../../payload/missingReceiptsPayload");
11
11
  const missingReceiptsViewReducer_1 = require("../../reducers/missingReceiptsViewReducer");
12
+ const missingReceiptsViewState_1 = require("../../types/missingReceiptsViewState");
12
13
  const transactionsViewState_1 = require("../../types/transactionsViewState");
13
14
  /**
14
15
  * `auto_categorized` for manual transaction search (Unmatched).
@@ -19,12 +20,17 @@ exports.MANUAL_TRANSACTION_SEARCH_AUTO_CATEGORIZED = false;
19
20
  const searchTransactionsForManualMatchEpic = (actions$, state$, zeniAPI) => {
20
21
  const searchActions$ = actions$.pipe((0, operators_1.filter)(missingReceiptsViewReducer_1.searchTransactionsForManualMatch.match));
21
22
  const pagination$ = searchActions$.pipe((0, operators_1.filter)((a) => a.payload.pageToken != null));
22
- /** Clears: no debounce so switchMap cancels in-flight HTTP from the previous query immediately. */
23
- const newSearchClear$ = searchActions$.pipe((0, operators_1.filter)((a) => a.payload.pageToken == null && a.payload.query.trim() === ''));
24
- const newSearchDebounced$ = searchActions$.pipe((0, operators_1.filter)((a) => a.payload.pageToken == null && a.payload.query.trim() !== ''), (0, operators_1.debounceTime)(300));
25
- return (0, rxjs_1.merge)(pagination$, newSearchClear$, newSearchDebounced$).pipe((0, operators_1.switchMap)((action) => {
23
+ /**
24
+ * No API for empty or 1-char queries; immediate merge so switchMap cancels any in-flight HTTP.
25
+ */
26
+ const newSearchTooShortOrClear$ = searchActions$.pipe((0, operators_1.filter)((a) => a.payload.pageToken == null &&
27
+ a.payload.query.trim().length < missingReceiptsViewState_1.MIN_MANUAL_TRANSACTION_SEARCH_LENGTH));
28
+ const newSearchDebounced$ = searchActions$.pipe((0, operators_1.filter)((a) => a.payload.pageToken == null &&
29
+ a.payload.query.trim().length >= missingReceiptsViewState_1.MIN_MANUAL_TRANSACTION_SEARCH_LENGTH), (0, operators_1.debounceTime)(300));
30
+ return (0, rxjs_1.merge)(pagination$, newSearchTooShortOrClear$, newSearchDebounced$).pipe((0, operators_1.switchMap)((action) => {
26
31
  const { query, pageToken } = action.payload;
27
- if (pageToken == null && query.trim() === '') {
32
+ if (pageToken == null &&
33
+ query.trim().length < missingReceiptsViewState_1.MIN_MANUAL_TRANSACTION_SEARCH_LENGTH) {
28
34
  return rxjs_1.EMPTY;
29
35
  }
30
36
  const state = state$.value;
@@ -5,7 +5,7 @@ import { MonthYearPeriod, TimePeriod } from '../../../commonStateTypes/timePerio
5
5
  import { TransactionPayload } from '../../../entity/transaction/payloadTypes/transactionPayload';
6
6
  import { SupportedTransactionPayload } from '../../../entity/transaction/transactionState';
7
7
  import { ZeniAPIStatus } from '../../../responsePayload';
8
- import type { BatchDetails, BatchListItem, BatchStatus, BulkUploadResultsTab, BulkUploadSortKey, BulkUploadState, CompletedSubTab, ManualSearchResult, MissingReceiptsViewState, MissingReceiptsViewUIState } from '../types/missingReceiptsViewState';
8
+ import { type BatchDetails, type BatchListItem, type BatchStatus, type BulkUploadResultsTab, type BulkUploadSortKey, type BulkUploadState, type CompletedSubTab, type ManualSearchResult, type MissingReceiptsViewState, type MissingReceiptsViewUIState } from '../types/missingReceiptsViewState';
9
9
  import type { MonthYearPeriodId } from '../../../commonStateTypes/timePeriod';
10
10
  export declare const getCompletedTransactionsCacheKey: (periodId: MonthYearPeriodId, sortKey: BulkUploadSortKey, sortOrder: SortOrder, subTab: CompletedSubTab) => string;
11
11
  export declare const initialBulkUploadState: BulkUploadState;
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.fetchCompletedTransactionsFailure = exports.fetchCompletedTransactionsSuccess = exports.fetchCompletedTransactions = exports.acknowledgeBulkUploadConfirmMatchComplete = exports.clearManualSearchResults = exports.searchTransactionsForManualMatchFailure = exports.searchTransactionsForManualMatchSuccess = exports.searchTransactionsForManualMatch = exports.clearBulkUpload = exports.setBulkUploadSortConfig = exports.setBulkUploadCompletedSubTab = exports.setBulkUploadResultsTab = exports.confirmBulkUploadMatchFailure = exports.confirmBulkUploadMatchSuccess = exports.confirmBulkUploadMatch = exports.fetchBulkUploadBatchesFailure = exports.fetchBulkUploadBatchesSuccess = exports.fetchBulkUploadBatches = exports.fetchMoreBatchDetailsFailure = exports.fetchMoreBatchDetailsComplete = exports.fetchMoreBatchDetails = exports.setInitialBatchDetailsLoading = exports.batchDetailFetchFailed = exports.storeBatchDetails = exports.fetchBulkUploadBatchDetailsFailure = exports.fetchBulkUploadBatchDetailsSuccess = exports.fetchBulkUploadBatchDetails = exports.clearMissingReceiptsTabNavigation = exports.requestMissingReceiptsTabNavigation = exports.pusherBatchStatusUpdate = exports.bulkUploadReceiptsFailure = exports.bulkUploadReceiptsSuccess = exports.updateBulkUploadProgress = exports.bulkUploadReceipts = exports.clearExpenseAutomationMissingReceiptsView = exports.markMissingReceiptAsDone = exports.updateMissingReceiptsUIState = exports.updateMissingReceiptUploadState = exports.uploadMissingReceiptSuccess = exports.fetchMissingReceiptsFailure = exports.fetchMissingReceiptsSuccess = exports.fetchMissingReceipts = exports.initialState = exports.initialBulkUploadState = exports.getCompletedTransactionsCacheKey = void 0;
5
5
  const toolkit_1 = require("@reduxjs/toolkit");
6
6
  const timePeriod_1 = require("../../../commonStateTypes/timePeriod");
7
+ const missingReceiptsViewState_1 = require("../types/missingReceiptsViewState");
7
8
  const getCompletedTransactionsCacheKey = (periodId, sortKey, sortOrder, subTab) => `completed-${subTab}-${sortKey}-${sortOrder === 'ascending' ? 'asc' : 'desc'}-${periodId}`;
8
9
  exports.getCompletedTransactionsCacheKey = getCompletedTransactionsCacheKey;
9
10
  exports.initialBulkUploadState = {
@@ -391,10 +392,11 @@ const expenseAutomationMissingReceiptsView = (0, toolkit_1.createSlice)({
391
392
  const isLoadMore = pageToken != null;
392
393
  const trimmed = query.trim();
393
394
  /**
394
- * Cleared input: reset fully (no In-Progress) so we never show a loader with stale rows,
395
- * and the epic can cancel any in-flight search via switchMap without a debounce delay.
395
+ * Cleared or too-short query: no API (see epic). Reset fully (no In-Progress) so loading
396
+ * UI never shows; bump key so inputs remount.
396
397
  */
397
- if (!isLoadMore && trimmed === '') {
398
+ if (!isLoadMore &&
399
+ trimmed.length < missingReceiptsViewState_1.MIN_MANUAL_TRANSACTION_SEARCH_LENGTH) {
398
400
  draft.bulkUpload.manualSearch = exports.initialBulkUploadState.manualSearch;
399
401
  draft.bulkUpload.manualSearchUiResetKey += 1;
400
402
  return;
@@ -13,6 +13,11 @@ export interface MissingReceiptsViewUIState {
13
13
  sortKey: MissingReceiptsSortKey;
14
14
  sortOrder: SortOrder;
15
15
  }
16
+ /**
17
+ * Minimum trimmed query length before manual-match search calls the expense-automation API.
18
+ * Kept in sync with `ManualSearchInput` in web-components (fires search only when length ≥ this).
19
+ */
20
+ export declare const MIN_MANUAL_TRANSACTION_SEARCH_LENGTH = 2;
16
21
  export type BatchStatusValue = 'pending' | 'processing' | 'completed';
17
22
  export type BatchFileStatus = 'matched' | 'un_matched' | 'no_match' | 'failed';
18
23
  export type BulkUploadPhase = 'idle' | 'uploading' | 'matching' | 'completed';
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toMissingReceiptsSortKey = void 0;
3
+ exports.MIN_MANUAL_TRANSACTION_SEARCH_LENGTH = exports.toMissingReceiptsSortKey = void 0;
4
4
  const stringToUnion_1 = require("../../../commonStateTypes/stringToUnion");
5
5
  const MISSING_RECEIPTS_SORT_KEYS = [
6
6
  'vendor',
@@ -11,3 +11,9 @@ const MISSING_RECEIPTS_SORT_KEYS = [
11
11
  ];
12
12
  const toMissingReceiptsSortKey = (v) => (0, stringToUnion_1.stringToUnion)(v, MISSING_RECEIPTS_SORT_KEYS);
13
13
  exports.toMissingReceiptsSortKey = toMissingReceiptsSortKey;
14
+ // -- Bulk Receipt Upload Types --
15
+ /**
16
+ * Minimum trimmed query length before manual-match search calls the expense-automation API.
17
+ * Kept in sync with `ManualSearchInput` in web-components (fires search only when length ≥ this).
18
+ */
19
+ exports.MIN_MANUAL_TRANSACTION_SEARCH_LENGTH = 2;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "4.19.84-betaVR4",
3
+ "version": "4.19.84-betaVR5",
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",