@zeniai/client-epic-state 4.19.37-betaVR7 → 4.19.37-betaVR8

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.
@@ -4,50 +4,13 @@ import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePay
4
4
  import { bulkUploadReceipts, bulkUploadReceiptsFailure, bulkUploadReceiptsSuccess, } from '../../reducers/missingReceiptsViewReducer';
5
5
  export const bulkUploadReceiptsEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(bulkUploadReceipts.match), mergeMap((action) => {
6
6
  const { files } = action.payload;
7
- // #region agent log
8
- fetch('http://127.0.0.1:7645/ingest/3d281ada-4e8f-4f88-b6d6-ac0851976786', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-Debug-Session-Id': '171bc9' }, body: JSON.stringify({ sessionId: '171bc9', location: 'bulkUploadReceiptsEpic.ts:31', message: 'files from action.payload', data: { fileCount: files?.length, filesType: typeof files, isArray: Array.isArray(files), fileDetails: files?.map((f) => ({ name: f?.name, size: f?.size, type: f?.type, isFile: f instanceof File, isBlobLike: f instanceof Blob, constructor: f?.constructor?.name })) }, timestamp: Date.now(), runId: 'run2', hypothesisId: 'H-A' }) }).catch(() => { });
9
- // #endregion
10
7
  const formData = new FormData();
11
8
  for (const file of files) {
12
9
  formData.append('files', file, file.name);
13
10
  }
14
- // #region agent log
15
- const fdEntries = [];
16
- formData.forEach((value, key) => { fdEntries.push({ key, type: typeof value, isFile: value instanceof File, isBlob: value instanceof Blob, name: value?.name, size: value?.size, constructor: value?.constructor?.name }); });
17
- fetch('http://127.0.0.1:7645/ingest/3d281ada-4e8f-4f88-b6d6-ac0851976786', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-Debug-Session-Id': '171bc9' }, body: JSON.stringify({ sessionId: '171bc9', location: 'bulkUploadReceiptsEpic.ts:38', message: 'FormData entries before send', data: { entryCount: fdEntries.length, entries: fdEntries }, timestamp: Date.now(), runId: 'run2', hypothesisId: 'H-B' }) }).catch(() => { });
18
- // #endregion
19
- const uploadUrl = `${zeniAPI.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/receipts/bulk-upload`;
20
- // #region agent log – diagnostic: direct fetch bypassing postFormData, test field name "file" (singular)
21
- const diagFormData = new FormData();
22
- for (const f of files) {
23
- diagFormData.append('file', f, f.name);
24
- }
25
- const diagHeaders = {};
26
- const ah = zeniAPI.apiHeaders();
27
- Object.keys(ah).forEach((k) => { if (k !== 'Content-Type') {
28
- diagHeaders[k] = ah[k];
29
- } });
30
- fetch(uploadUrl, { method: 'POST', body: diagFormData, headers: diagHeaders })
31
- .then((r) => r.text().then((t) => {
32
- fetch('http://127.0.0.1:7645/ingest/3d281ada-4e8f-4f88-b6d6-ac0851976786', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-Debug-Session-Id': '171bc9' }, body: JSON.stringify({ sessionId: '171bc9', location: 'bulkUploadReceiptsEpic.ts:diag-file', message: 'DIAG direct fetch field=file', data: { status: r.status, body: t, redirected: r.redirected, url: r.url }, timestamp: Date.now(), runId: 'run3', hypothesisId: 'H-K' }) }).catch(() => { });
33
- })).catch(() => { });
34
- // #endregion
35
- // #region agent log – diagnostic: direct fetch bypassing postFormData, test field name "receipt_files"
36
- const diagFormData2 = new FormData();
37
- for (const f of files) {
38
- diagFormData2.append('receipt_files', f, f.name);
39
- }
40
- fetch(uploadUrl, { method: 'POST', body: diagFormData2, headers: diagHeaders })
41
- .then((r) => r.text().then((t) => {
42
- fetch('http://127.0.0.1:7645/ingest/3d281ada-4e8f-4f88-b6d6-ac0851976786', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-Debug-Session-Id': '171bc9' }, body: JSON.stringify({ sessionId: '171bc9', location: 'bulkUploadReceiptsEpic.ts:diag-receipt_files', message: 'DIAG direct fetch field=receipt_files', data: { status: r.status, body: t, redirected: r.redirected, url: r.url }, timestamp: Date.now(), runId: 'run3', hypothesisId: 'H-K' }) }).catch(() => { });
43
- })).catch(() => { });
44
- // #endregion
45
11
  return zeniAPI
46
- .postFormData(uploadUrl, formData)
12
+ .postFormData(`${zeniAPI.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/receipts/bulk-upload`, formData)
47
13
  .pipe(mergeMap((response) => {
48
- // #region agent log
49
- fetch('http://127.0.0.1:7645/ingest/3d281ada-4e8f-4f88-b6d6-ac0851976786', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-Debug-Session-Id': '171bc9' }, body: JSON.stringify({ sessionId: '171bc9', location: 'bulkUploadReceiptsEpic.ts:response', message: 'API response received', data: { isSuccess: isSuccessResponse(response), hasData: response.data != null, status: response.status, fullResponse: response }, timestamp: Date.now(), runId: 'run2', hypothesisId: 'H-H' }) }).catch(() => { });
50
- // #endregion
51
14
  if (isSuccessResponse(response) && response.data != null) {
52
15
  return of(bulkUploadReceiptsSuccess({
53
16
  batchId: response.data.batch_id,
@@ -81,22 +81,12 @@ export class ZeniAPIClient {
81
81
  postFormData(restEndPoint, formData, signal) {
82
82
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
83
83
  const { 'Content-Type': _contentType, ...headers } = this.apiHeaders();
84
- // #region agent log
85
- fetch('http://127.0.0.1:7645/ingest/3d281ada-4e8f-4f88-b6d6-ac0851976786', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-Debug-Session-Id': '171bc9' }, body: JSON.stringify({ sessionId: '171bc9', location: 'zeniAPI.ts:postFormData', message: 'postFormData headers and URL', data: { url: restEndPoint, headersKeys: Object.keys(headers), headersValues: headers }, timestamp: Date.now(), runId: 'run2', hypothesisId: 'H-G' }) }).catch(() => { });
86
- // #endregion
87
84
  const promise = fetch(restEndPoint, {
88
85
  method: 'POST',
89
86
  body: formData,
90
87
  headers,
91
88
  signal,
92
- }).then((response) => {
93
- // #region agent log
94
- const rh = {};
95
- response.headers.forEach((v, k) => { rh[k] = v; });
96
- fetch('http://127.0.0.1:7645/ingest/3d281ada-4e8f-4f88-b6d6-ac0851976786', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-Debug-Session-Id': '171bc9' }, body: JSON.stringify({ sessionId: '171bc9', location: 'zeniAPI.ts:postFormData:response', message: 'fetch response metadata', data: { status: response.status, statusText: response.statusText, redirected: response.redirected, responseUrl: response.url, requestUrl: restEndPoint, urlMatch: response.url === restEndPoint, responseType: response.type, responseHeaders: rh }, timestamp: Date.now(), runId: 'run2', hypothesisId: 'H-F' }) }).catch(() => { });
97
- // #endregion
98
- return this.processJsonResponse(response);
99
- });
89
+ }).then((response) => this.processJsonResponse(response));
100
90
  return from(promise);
101
91
  }
102
92
  postFormDataWithProgress(restEndPoint, formData, signal) {
@@ -7,50 +7,13 @@ const responsePayload_1 = require("../../../../responsePayload");
7
7
  const missingReceiptsViewReducer_1 = require("../../reducers/missingReceiptsViewReducer");
8
8
  const bulkUploadReceiptsEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(missingReceiptsViewReducer_1.bulkUploadReceipts.match), (0, operators_1.mergeMap)((action) => {
9
9
  const { files } = action.payload;
10
- // #region agent log
11
- fetch('http://127.0.0.1:7645/ingest/3d281ada-4e8f-4f88-b6d6-ac0851976786', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-Debug-Session-Id': '171bc9' }, body: JSON.stringify({ sessionId: '171bc9', location: 'bulkUploadReceiptsEpic.ts:31', message: 'files from action.payload', data: { fileCount: files?.length, filesType: typeof files, isArray: Array.isArray(files), fileDetails: files?.map((f) => ({ name: f?.name, size: f?.size, type: f?.type, isFile: f instanceof File, isBlobLike: f instanceof Blob, constructor: f?.constructor?.name })) }, timestamp: Date.now(), runId: 'run2', hypothesisId: 'H-A' }) }).catch(() => { });
12
- // #endregion
13
10
  const formData = new FormData();
14
11
  for (const file of files) {
15
12
  formData.append('files', file, file.name);
16
13
  }
17
- // #region agent log
18
- const fdEntries = [];
19
- formData.forEach((value, key) => { fdEntries.push({ key, type: typeof value, isFile: value instanceof File, isBlob: value instanceof Blob, name: value?.name, size: value?.size, constructor: value?.constructor?.name }); });
20
- fetch('http://127.0.0.1:7645/ingest/3d281ada-4e8f-4f88-b6d6-ac0851976786', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-Debug-Session-Id': '171bc9' }, body: JSON.stringify({ sessionId: '171bc9', location: 'bulkUploadReceiptsEpic.ts:38', message: 'FormData entries before send', data: { entryCount: fdEntries.length, entries: fdEntries }, timestamp: Date.now(), runId: 'run2', hypothesisId: 'H-B' }) }).catch(() => { });
21
- // #endregion
22
- const uploadUrl = `${zeniAPI.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/receipts/bulk-upload`;
23
- // #region agent log – diagnostic: direct fetch bypassing postFormData, test field name "file" (singular)
24
- const diagFormData = new FormData();
25
- for (const f of files) {
26
- diagFormData.append('file', f, f.name);
27
- }
28
- const diagHeaders = {};
29
- const ah = zeniAPI.apiHeaders();
30
- Object.keys(ah).forEach((k) => { if (k !== 'Content-Type') {
31
- diagHeaders[k] = ah[k];
32
- } });
33
- fetch(uploadUrl, { method: 'POST', body: diagFormData, headers: diagHeaders })
34
- .then((r) => r.text().then((t) => {
35
- fetch('http://127.0.0.1:7645/ingest/3d281ada-4e8f-4f88-b6d6-ac0851976786', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-Debug-Session-Id': '171bc9' }, body: JSON.stringify({ sessionId: '171bc9', location: 'bulkUploadReceiptsEpic.ts:diag-file', message: 'DIAG direct fetch field=file', data: { status: r.status, body: t, redirected: r.redirected, url: r.url }, timestamp: Date.now(), runId: 'run3', hypothesisId: 'H-K' }) }).catch(() => { });
36
- })).catch(() => { });
37
- // #endregion
38
- // #region agent log – diagnostic: direct fetch bypassing postFormData, test field name "receipt_files"
39
- const diagFormData2 = new FormData();
40
- for (const f of files) {
41
- diagFormData2.append('receipt_files', f, f.name);
42
- }
43
- fetch(uploadUrl, { method: 'POST', body: diagFormData2, headers: diagHeaders })
44
- .then((r) => r.text().then((t) => {
45
- fetch('http://127.0.0.1:7645/ingest/3d281ada-4e8f-4f88-b6d6-ac0851976786', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-Debug-Session-Id': '171bc9' }, body: JSON.stringify({ sessionId: '171bc9', location: 'bulkUploadReceiptsEpic.ts:diag-receipt_files', message: 'DIAG direct fetch field=receipt_files', data: { status: r.status, body: t, redirected: r.redirected, url: r.url }, timestamp: Date.now(), runId: 'run3', hypothesisId: 'H-K' }) }).catch(() => { });
46
- })).catch(() => { });
47
- // #endregion
48
14
  return zeniAPI
49
- .postFormData(uploadUrl, formData)
15
+ .postFormData(`${zeniAPI.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/receipts/bulk-upload`, formData)
50
16
  .pipe((0, operators_1.mergeMap)((response) => {
51
- // #region agent log
52
- fetch('http://127.0.0.1:7645/ingest/3d281ada-4e8f-4f88-b6d6-ac0851976786', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-Debug-Session-Id': '171bc9' }, body: JSON.stringify({ sessionId: '171bc9', location: 'bulkUploadReceiptsEpic.ts:response', message: 'API response received', data: { isSuccess: (0, responsePayload_1.isSuccessResponse)(response), hasData: response.data != null, status: response.status, fullResponse: response }, timestamp: Date.now(), runId: 'run2', hypothesisId: 'H-H' }) }).catch(() => { });
53
- // #endregion
54
17
  if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
55
18
  return (0, rxjs_1.of)((0, missingReceiptsViewReducer_1.bulkUploadReceiptsSuccess)({
56
19
  batchId: response.data.batch_id,
package/lib/zeniAPI.js CHANGED
@@ -84,22 +84,12 @@ class ZeniAPIClient {
84
84
  postFormData(restEndPoint, formData, signal) {
85
85
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
86
86
  const { 'Content-Type': _contentType, ...headers } = this.apiHeaders();
87
- // #region agent log
88
- (0, cross_fetch_1.fetch)('http://127.0.0.1:7645/ingest/3d281ada-4e8f-4f88-b6d6-ac0851976786', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-Debug-Session-Id': '171bc9' }, body: JSON.stringify({ sessionId: '171bc9', location: 'zeniAPI.ts:postFormData', message: 'postFormData headers and URL', data: { url: restEndPoint, headersKeys: Object.keys(headers), headersValues: headers }, timestamp: Date.now(), runId: 'run2', hypothesisId: 'H-G' }) }).catch(() => { });
89
- // #endregion
90
87
  const promise = (0, cross_fetch_1.fetch)(restEndPoint, {
91
88
  method: 'POST',
92
89
  body: formData,
93
90
  headers,
94
91
  signal,
95
- }).then((response) => {
96
- // #region agent log
97
- const rh = {};
98
- response.headers.forEach((v, k) => { rh[k] = v; });
99
- (0, cross_fetch_1.fetch)('http://127.0.0.1:7645/ingest/3d281ada-4e8f-4f88-b6d6-ac0851976786', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-Debug-Session-Id': '171bc9' }, body: JSON.stringify({ sessionId: '171bc9', location: 'zeniAPI.ts:postFormData:response', message: 'fetch response metadata', data: { status: response.status, statusText: response.statusText, redirected: response.redirected, responseUrl: response.url, requestUrl: restEndPoint, urlMatch: response.url === restEndPoint, responseType: response.type, responseHeaders: rh }, timestamp: Date.now(), runId: 'run2', hypothesisId: 'H-F' }) }).catch(() => { });
100
- // #endregion
101
- return this.processJsonResponse(response);
102
- });
92
+ }).then((response) => this.processJsonResponse(response));
103
93
  return (0, rxjs_1.from)(promise);
104
94
  }
105
95
  postFormDataWithProgress(restEndPoint, formData, signal) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "4.19.37-betaVR7",
3
+ "version": "4.19.37-betaVR8",
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",