@zeniai/client-epic-state 5.3.16 → 5.3.17

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.
@@ -135,29 +135,13 @@ const prepareCreateTransactionPayload = (state, localData) => {
135
135
  };
136
136
  }
137
137
  const lines = localData.lines.map((line) => toLinePayload(state, line, transactionType));
138
- const documentIdField = localData.documentNumber != null && localData.documentNumber !== ''
139
- ? { document_id: localData.documentNumber }
140
- : {};
141
138
  if (transactionType === 'journal_entry') {
142
- return { ...base, ...documentIdField, lines };
143
- }
144
- // Both post to accounts payable, so they carry no header account or payment type.
145
- if (transactionType === 'vendor_credit') {
146
- return {
147
- ...base,
148
- vendor_id: toQboVendorId(state, localData.vendorId),
149
- ...documentIdField,
150
- lines,
151
- };
152
- }
153
- if (transactionType === 'bill') {
154
139
  return {
155
140
  ...base,
156
- vendor_id: toQboVendorId(state, localData.vendorId),
157
- ...(localData.dueDate != null && {
158
- due_date: localData.dueDate.format(timePeriod_1.DEFAULT_DATE_FORMAT),
141
+ ...(localData.documentNumber != null &&
142
+ localData.documentNumber !== '' && {
143
+ document_id: localData.documentNumber,
159
144
  }),
160
- ...documentIdField,
161
145
  lines,
162
146
  };
163
147
  }
@@ -9,7 +9,7 @@ import { ZeniDate } from '../../../zeniDayJS';
9
9
  * The transaction types the Create Transaction flow can originate. A narrow subset of
10
10
  * TransactionType -- everything else is read-only and arrives via sync.
11
11
  */
12
- export declare const ALL_CREATABLE_TRANSACTION_TYPES: readonly ["expense", "check", "credit_card_credit", "transfer", "journal_entry", "bill", "vendor_credit"];
12
+ export declare const ALL_CREATABLE_TRANSACTION_TYPES: readonly ["expense", "check", "credit_card_credit", "transfer", "journal_entry"];
13
13
  export type CreatableTransactionType = (typeof ALL_CREATABLE_TRANSACTION_TYPES)[number];
14
14
  /**
15
15
  * The wire shape the create endpoint expects for a check's remit-to address. Deliberately not
@@ -54,13 +54,8 @@ export interface CreateTransactionLocalData {
54
54
  /** Empty for transfer, which has no lines at all. */
55
55
  lines: CreateTransactionLineLocalData[];
56
56
  transactionType: CreatableTransactionType;
57
- /**
58
- * check / credit_card_credit / vendor_credit reference number, journal_entry entry name, or
59
- * bill number.
60
- */
57
+ /** check / credit_card_credit reference number, or the journal_entry entry name. */
61
58
  documentNumber?: string;
62
- /** bill only. */
63
- dueDate?: ZeniDate;
64
59
  /** transfer */
65
60
  fromAccountId?: ID;
66
61
  paymentType?: PaymentType;
@@ -11,6 +11,4 @@ exports.ALL_CREATABLE_TRANSACTION_TYPES = [
11
11
  'credit_card_credit',
12
12
  'transfer',
13
13
  'journal_entry',
14
- 'bill',
15
- 'vendor_credit',
16
14
  ];
@@ -177,39 +177,39 @@ export declare const downloadAccountingProviderAttachment: import("@reduxjs/tool
177
177
  }, "transactionDetail/deleteSplitLine", never, never>, toggleSplitEditMode: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[transactionId: TransactionID, editMode: boolean], {
178
178
  transactionId: TransactionID;
179
179
  editMode: boolean;
180
- }, "transactionDetail/toggleSplitEditMode", never, never>, initializeCreateTransactionLocalData: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[transactionType: "expense" | "check" | "bill" | "vendor_credit" | "credit_card_credit" | "transfer" | "journal_entry"], {
181
- transactionType: "expense" | "check" | "bill" | "vendor_credit" | "credit_card_credit" | "transfer" | "journal_entry";
182
- }, "transactionDetail/initializeCreateTransactionLocalData", never, never>, updateCreateTransactionLocalData: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[transactionType: "expense" | "check" | "bill" | "vendor_credit" | "credit_card_credit" | "transfer" | "journal_entry", localData: Partial<CreateTransactionLocalData>], {
183
- transactionType: "expense" | "check" | "bill" | "vendor_credit" | "credit_card_credit" | "transfer" | "journal_entry";
180
+ }, "transactionDetail/toggleSplitEditMode", never, never>, initializeCreateTransactionLocalData: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[transactionType: "expense" | "check" | "credit_card_credit" | "transfer" | "journal_entry"], {
181
+ transactionType: "expense" | "check" | "credit_card_credit" | "transfer" | "journal_entry";
182
+ }, "transactionDetail/initializeCreateTransactionLocalData", never, never>, updateCreateTransactionLocalData: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[transactionType: "expense" | "check" | "credit_card_credit" | "transfer" | "journal_entry", localData: Partial<CreateTransactionLocalData>], {
183
+ transactionType: "expense" | "check" | "credit_card_credit" | "transfer" | "journal_entry";
184
184
  localData: Partial<CreateTransactionLocalData>;
185
- }, "transactionDetail/updateCreateTransactionLocalData", never, never>, updateCreateTransactionLineLocalData: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[transactionType: "expense" | "check" | "bill" | "vendor_credit" | "credit_card_credit" | "transfer" | "journal_entry", lineId: string, lineUpdates: Partial<CreateTransactionLineLocalData>], {
186
- transactionType: "expense" | "check" | "bill" | "vendor_credit" | "credit_card_credit" | "transfer" | "journal_entry";
185
+ }, "transactionDetail/updateCreateTransactionLocalData", never, never>, updateCreateTransactionLineLocalData: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[transactionType: "expense" | "check" | "credit_card_credit" | "transfer" | "journal_entry", lineId: string, lineUpdates: Partial<CreateTransactionLineLocalData>], {
186
+ transactionType: "expense" | "check" | "credit_card_credit" | "transfer" | "journal_entry";
187
187
  lineId: string;
188
188
  lineUpdates: Partial<CreateTransactionLineLocalData>;
189
- }, "transactionDetail/updateCreateTransactionLineLocalData", never, never>, addCreateTransactionLine: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[transactionType: "expense" | "check" | "bill" | "vendor_credit" | "credit_card_credit" | "transfer" | "journal_entry", line?: Partial<CreateTransactionLineLocalData> | undefined], {
190
- transactionType: "expense" | "check" | "bill" | "vendor_credit" | "credit_card_credit" | "transfer" | "journal_entry";
189
+ }, "transactionDetail/updateCreateTransactionLineLocalData", never, never>, addCreateTransactionLine: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[transactionType: "expense" | "check" | "credit_card_credit" | "transfer" | "journal_entry", line?: Partial<CreateTransactionLineLocalData> | undefined], {
190
+ transactionType: "expense" | "check" | "credit_card_credit" | "transfer" | "journal_entry";
191
191
  line: Partial<CreateTransactionLineLocalData> | undefined;
192
- }, "transactionDetail/addCreateTransactionLine", never, never>, removeCreateTransactionLine: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[transactionType: "expense" | "check" | "bill" | "vendor_credit" | "credit_card_credit" | "transfer" | "journal_entry", lineId: string], {
193
- transactionType: "expense" | "check" | "bill" | "vendor_credit" | "credit_card_credit" | "transfer" | "journal_entry";
192
+ }, "transactionDetail/addCreateTransactionLine", never, never>, removeCreateTransactionLine: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[transactionType: "expense" | "check" | "credit_card_credit" | "transfer" | "journal_entry", lineId: string], {
193
+ transactionType: "expense" | "check" | "credit_card_credit" | "transfer" | "journal_entry";
194
194
  lineId: string;
195
- }, "transactionDetail/removeCreateTransactionLine", never, never>, resetCreateTransactionLocalData: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[transactionType: "expense" | "check" | "bill" | "vendor_credit" | "credit_card_credit" | "transfer" | "journal_entry"], {
196
- transactionType: "expense" | "check" | "bill" | "vendor_credit" | "credit_card_credit" | "transfer" | "journal_entry";
197
- }, "transactionDetail/resetCreateTransactionLocalData", never, never>, createTransaction: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[transactionType: "expense" | "check" | "bill" | "vendor_credit" | "credit_card_credit" | "transfer" | "journal_entry"], {
198
- transactionType: "expense" | "check" | "bill" | "vendor_credit" | "credit_card_credit" | "transfer" | "journal_entry";
195
+ }, "transactionDetail/removeCreateTransactionLine", never, never>, resetCreateTransactionLocalData: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[transactionType: "expense" | "check" | "credit_card_credit" | "transfer" | "journal_entry"], {
196
+ transactionType: "expense" | "check" | "credit_card_credit" | "transfer" | "journal_entry";
197
+ }, "transactionDetail/resetCreateTransactionLocalData", never, never>, createTransaction: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[transactionType: "expense" | "check" | "credit_card_credit" | "transfer" | "journal_entry"], {
198
+ transactionType: "expense" | "check" | "credit_card_credit" | "transfer" | "journal_entry";
199
199
  }, "transactionDetail/createTransaction", never, never>, createTransactionSuccessOrFailure: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[fetchState: FetchState, createdTransactionId?: TransactionID | undefined, error?: ZeniAPIStatus<Record<string, unknown>> | undefined], {
200
200
  fetchState: FetchState;
201
201
  createdTransactionId: TransactionID | undefined;
202
202
  error: ZeniAPIStatus<Record<string, unknown>> | undefined;
203
- }, "transactionDetail/createTransactionSuccessOrFailure", never, never>, setRecommendationsForCreateTransactionLines: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[transactionType: "expense" | "check" | "bill" | "vendor_credit" | "credit_card_credit" | "transfer" | "journal_entry", lineIds: string[], recommendations: Recommendation[], isAccountingClassesEnabled: boolean], {
204
- transactionType: "expense" | "check" | "bill" | "vendor_credit" | "credit_card_credit" | "transfer" | "journal_entry";
203
+ }, "transactionDetail/createTransactionSuccessOrFailure", never, never>, setRecommendationsForCreateTransactionLines: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[transactionType: "expense" | "check" | "credit_card_credit" | "transfer" | "journal_entry", lineIds: string[], recommendations: Recommendation[], isAccountingClassesEnabled: boolean], {
204
+ transactionType: "expense" | "check" | "credit_card_credit" | "transfer" | "journal_entry";
205
205
  lineIds: string[];
206
206
  recommendations: Recommendation[];
207
207
  isAccountingClassesEnabled: boolean;
208
- }, "transactionDetail/setRecommendationsForCreateTransactionLines", never, never>, clearRecommendationsForCreateTransactionLines: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[transactionType: "expense" | "check" | "bill" | "vendor_credit" | "credit_card_credit" | "transfer" | "journal_entry", lineIds: string[]], {
209
- transactionType: "expense" | "check" | "bill" | "vendor_credit" | "credit_card_credit" | "transfer" | "journal_entry";
208
+ }, "transactionDetail/setRecommendationsForCreateTransactionLines", never, never>, clearRecommendationsForCreateTransactionLines: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[transactionType: "expense" | "check" | "credit_card_credit" | "transfer" | "journal_entry", lineIds: string[]], {
209
+ transactionType: "expense" | "check" | "credit_card_credit" | "transfer" | "journal_entry";
210
210
  lineIds: string[];
211
- }, "transactionDetail/clearRecommendationsForCreateTransactionLines", never, never>, fetchVendorRecommendationsForCreateTransaction: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[transactionType: "expense" | "check" | "bill" | "vendor_credit" | "credit_card_credit" | "transfer" | "journal_entry", lineIds: string[], entity?: Entity | undefined], {
212
- transactionType: "expense" | "check" | "bill" | "vendor_credit" | "credit_card_credit" | "transfer" | "journal_entry";
211
+ }, "transactionDetail/clearRecommendationsForCreateTransactionLines", never, never>, fetchVendorRecommendationsForCreateTransaction: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[transactionType: "expense" | "check" | "credit_card_credit" | "transfer" | "journal_entry", lineIds: string[], entity?: Entity | undefined], {
212
+ transactionType: "expense" | "check" | "credit_card_credit" | "transfer" | "journal_entry";
213
213
  lineIds: string[];
214
214
  entity: Entity | undefined;
215
215
  }, "transactionDetail/fetchVendorRecommendationsForCreateTransaction", never, never>, createTransactionAttachmentUploadFailure: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[failedAttachmentFileNames: string[]], {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "5.3.16",
3
+ "version": "5.3.17",
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,60 +0,0 @@
1
- import { of } from 'rxjs';
2
- import { catchError, filter, finalize, map, switchMap, takeUntil, timeout, } from 'rxjs/operators';
3
- import { createZeniAPIStatus, isSuccessResponse, } from '../../../responsePayload';
4
- import { clearAll } from '../../../rootActions';
5
- import { transcribeAudio, transcribeAudioFailure, transcribeAudioSuccess, } from '../aiCfoViewReducer';
6
- const AUDIO_FIELD = 'audio';
7
- const LANGUAGE_FIELD = 'language';
8
- /** Extension only has to match the recorded format; the server reads the part's MIME type. */
9
- const AUDIO_FILE_NAME = 'dictation.wav';
10
- /**
11
- * A hung request would otherwise pin `isTranscribing` true forever, and the composer
12
- * gates both submit and the mic on it — leaving the user unable to send even typed
13
- * text until something else resolved it.
14
- */
15
- const TRANSCRIPTION_TIMEOUT_MS = 30000;
16
- /**
17
- * Voice dictation for the AI CFO composer. Dispatch `transcribeAudio(blob, language)` with a
18
- * finished recording to POST it to the AI CFO micro-service `/1.0/transcriptions` endpoint;
19
- * on success the transcript is appended to the composer input for the user to edit and send.
20
- *
21
- * `switchMap` (not `mergeMap`): a newer recording supersedes an older in-flight one, so a
22
- * slow response can never append a stale transcript after a fresh one has already landed.
23
- * The AbortController makes that cancellation real — `fetch` wrapped in a promise ignores
24
- * an RxJS unsubscribe, so without the signal the superseded request would run to completion
25
- * and still bill a transcription call whose result nothing wants.
26
- */
27
- export const transcribeAudioEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(transcribeAudio.match), switchMap((action) => {
28
- const { audio, chatSessionId, language } = action.payload;
29
- const abortController = new AbortController();
30
- const formData = new FormData();
31
- formData.append(AUDIO_FIELD, audio, AUDIO_FILE_NAME);
32
- if (language != null && language !== '') {
33
- formData.append(LANGUAGE_FIELD, language);
34
- }
35
- return zeniAPI
36
- .postFormData(`${zeniAPI.apiEndPoints.aiCfoMicroServiceBaseUrl}/1.0/transcriptions`, formData, abortController.signal)
37
- .pipe(timeout(TRANSCRIPTION_TIMEOUT_MS),
38
- // A tenant switch clears the store; a transcript still in flight must not
39
- // land in the next tenant's composer (both sessions can be `undefined`, so
40
- // the reducer's session guard would let it through).
41
- takeUntil(actions$.pipe(filter(clearAll.match))), map((response) => {
42
- if (!isSuccessResponse(response)) {
43
- return transcribeAudioFailure(response.status);
44
- }
45
- // An EMPTY transcript is a success (the mic caught silence) and the
46
- // reducer leaves the composer alone. A MISSING one breaks the response
47
- // contract, so it surfaces as an error rather than being coerced to
48
- // silence the user cannot distinguish from a quiet room.
49
- if (response.data?.transcript == null) {
50
- return transcribeAudioFailure(createZeniAPIStatus('Transcription succeeded but the response carried no transcript', 'Unexpected Error'));
51
- }
52
- // The session id rides along so a transcript that lands after the user
53
- // switched sessions is dropped rather than misfiled.
54
- return transcribeAudioSuccess(response.data.transcript, chatSessionId);
55
- }), finalize(() => abortController.abort()), catchError((error) => of(transcribeAudioFailure(createZeniAPIStatus(
56
- // message (detailed) first, then the short title — per createZeniAPIStatus(message, title).
57
- // JSON.stringify(Error) drops the (non-enumerable) message — extract it explicitly.
58
- 'Transcription REST API call errored out: ' +
59
- (error instanceof Error ? error.message : String(error)), 'Unexpected Error')))));
60
- }));
@@ -1,19 +0,0 @@
1
- import { ActionsObservable, StateObservable } from 'redux-observable';
2
- import { Observable } from 'rxjs';
3
- import { clearAll } from '../../../rootActions';
4
- import { RootState } from '../../../rootStateTypes';
5
- import { ZeniAPI } from '../../../zeniAPI';
6
- import { transcribeAudio, transcribeAudioFailure, transcribeAudioSuccess } from '../aiCfoViewReducer';
7
- export type ActionType = ReturnType<typeof clearAll> | ReturnType<typeof transcribeAudio> | ReturnType<typeof transcribeAudioSuccess> | ReturnType<typeof transcribeAudioFailure>;
8
- /**
9
- * Voice dictation for the AI CFO composer. Dispatch `transcribeAudio(blob, language)` with a
10
- * finished recording to POST it to the AI CFO micro-service `/1.0/transcriptions` endpoint;
11
- * on success the transcript is appended to the composer input for the user to edit and send.
12
- *
13
- * `switchMap` (not `mergeMap`): a newer recording supersedes an older in-flight one, so a
14
- * slow response can never append a stale transcript after a fresh one has already landed.
15
- * The AbortController makes that cancellation real — `fetch` wrapped in a promise ignores
16
- * an RxJS unsubscribe, so without the signal the superseded request would run to completion
17
- * and still bill a transcription call whose result nothing wants.
18
- */
19
- export declare const transcribeAudioEpic: (actions$: ActionsObservable<ActionType>, _state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -1,64 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.transcribeAudioEpic = void 0;
4
- const rxjs_1 = require("rxjs");
5
- const operators_1 = require("rxjs/operators");
6
- const responsePayload_1 = require("../../../responsePayload");
7
- const rootActions_1 = require("../../../rootActions");
8
- const aiCfoViewReducer_1 = require("../aiCfoViewReducer");
9
- const AUDIO_FIELD = 'audio';
10
- const LANGUAGE_FIELD = 'language';
11
- /** Extension only has to match the recorded format; the server reads the part's MIME type. */
12
- const AUDIO_FILE_NAME = 'dictation.wav';
13
- /**
14
- * A hung request would otherwise pin `isTranscribing` true forever, and the composer
15
- * gates both submit and the mic on it — leaving the user unable to send even typed
16
- * text until something else resolved it.
17
- */
18
- const TRANSCRIPTION_TIMEOUT_MS = 30000;
19
- /**
20
- * Voice dictation for the AI CFO composer. Dispatch `transcribeAudio(blob, language)` with a
21
- * finished recording to POST it to the AI CFO micro-service `/1.0/transcriptions` endpoint;
22
- * on success the transcript is appended to the composer input for the user to edit and send.
23
- *
24
- * `switchMap` (not `mergeMap`): a newer recording supersedes an older in-flight one, so a
25
- * slow response can never append a stale transcript after a fresh one has already landed.
26
- * The AbortController makes that cancellation real — `fetch` wrapped in a promise ignores
27
- * an RxJS unsubscribe, so without the signal the superseded request would run to completion
28
- * and still bill a transcription call whose result nothing wants.
29
- */
30
- const transcribeAudioEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(aiCfoViewReducer_1.transcribeAudio.match), (0, operators_1.switchMap)((action) => {
31
- const { audio, chatSessionId, language } = action.payload;
32
- const abortController = new AbortController();
33
- const formData = new FormData();
34
- formData.append(AUDIO_FIELD, audio, AUDIO_FILE_NAME);
35
- if (language != null && language !== '') {
36
- formData.append(LANGUAGE_FIELD, language);
37
- }
38
- return zeniAPI
39
- .postFormData(`${zeniAPI.apiEndPoints.aiCfoMicroServiceBaseUrl}/1.0/transcriptions`, formData, abortController.signal)
40
- .pipe((0, operators_1.timeout)(TRANSCRIPTION_TIMEOUT_MS),
41
- // A tenant switch clears the store; a transcript still in flight must not
42
- // land in the next tenant's composer (both sessions can be `undefined`, so
43
- // the reducer's session guard would let it through).
44
- (0, operators_1.takeUntil)(actions$.pipe((0, operators_1.filter)(rootActions_1.clearAll.match))), (0, operators_1.map)((response) => {
45
- if (!(0, responsePayload_1.isSuccessResponse)(response)) {
46
- return (0, aiCfoViewReducer_1.transcribeAudioFailure)(response.status);
47
- }
48
- // An EMPTY transcript is a success (the mic caught silence) and the
49
- // reducer leaves the composer alone. A MISSING one breaks the response
50
- // contract, so it surfaces as an error rather than being coerced to
51
- // silence the user cannot distinguish from a quiet room.
52
- if (response.data?.transcript == null) {
53
- return (0, aiCfoViewReducer_1.transcribeAudioFailure)((0, responsePayload_1.createZeniAPIStatus)('Transcription succeeded but the response carried no transcript', 'Unexpected Error'));
54
- }
55
- // The session id rides along so a transcript that lands after the user
56
- // switched sessions is dropped rather than misfiled.
57
- return (0, aiCfoViewReducer_1.transcribeAudioSuccess)(response.data.transcript, chatSessionId);
58
- }), (0, operators_1.finalize)(() => abortController.abort()), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, aiCfoViewReducer_1.transcribeAudioFailure)((0, responsePayload_1.createZeniAPIStatus)(
59
- // message (detailed) first, then the short title — per createZeniAPIStatus(message, title).
60
- // JSON.stringify(Error) drops the (non-enumerable) message — extract it explicitly.
61
- 'Transcription REST API call errored out: ' +
62
- (error instanceof Error ? error.message : String(error)), 'Unexpected Error')))));
63
- }));
64
- exports.transcribeAudioEpic = transcribeAudioEpic;