cat-documents-ng 0.4.2 → 0.4.4

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.
@@ -49,11 +49,7 @@ export declare class DocumentContainerComponent implements OnInit, OnDestroy, On
49
49
  */
50
50
  contentScrollContainer: ElementRef;
51
51
  selectedDocument: EventEmitter<any>;
52
- emitSelectedDocumentInNewTab: EventEmitter<{
53
- selectedDocument: any;
54
- contextId: string;
55
- documentList: any[];
56
- }>;
52
+ selectedDocumentInNewTab: EventEmitter<any>;
57
53
  /**
58
54
  * Subscription to track selected menu item changes
59
55
  */
@@ -131,6 +127,11 @@ export declare class DocumentContainerComponent implements OnInit, OnDestroy, On
131
127
  * to trigger status data fetching and user list refreshing
132
128
  */
133
129
  setupStatusDataSubscriptions(): void;
130
+ onDocumentSelectedInNewTab(event: {
131
+ selectedDocument: any;
132
+ contextId: string;
133
+ documentList: any[];
134
+ }): void;
134
135
  /**
135
136
  * Fetches status data based on current selections
136
137
  */
@@ -151,24 +152,11 @@ export declare class DocumentContainerComponent implements OnInit, OnDestroy, On
151
152
  * Sets up subscription to listen for filtered document responses
152
153
  */
153
154
  setupFilteredDocumentSubscription(): void;
154
- /**
155
- * Handles the selected document event
156
- * @param document - The document to be selected
157
- */
158
155
  onDocumentSelected(document: any): void;
159
- /**
160
- * Handles the selected document in new tab event
161
- * @param data - The data containing the selected document, contextId, and document list
162
- */
163
- handleSelectedDocumentInNewTab(data: {
164
- selectedDocument: any;
165
- contextId: string;
166
- documentList: any[];
167
- }): void;
168
156
  /**
169
157
  * Unsubscribe subscription on destroy of component and clean up state.
170
158
  */
171
159
  ngOnDestroy(): void;
172
160
  static ɵfac: i0.ɵɵFactoryDeclaration<DocumentContainerComponent, never>;
173
- static ɵcmp: i0.ɵɵComponentDeclaration<DocumentContainerComponent, "lib-document-container", never, { "contextId": { "alias": "contextId"; "required": false; }; }, { "selectedDocument": "selectedDocument"; "emitSelectedDocumentInNewTab": "emitSelectedDocumentInNewTab"; }, never, ["*"], false, never>;
161
+ static ɵcmp: i0.ɵɵComponentDeclaration<DocumentContainerComponent, "lib-document-container", never, { "contextId": { "alias": "contextId"; "required": false; }; }, { "selectedDocument": "selectedDocument"; "selectedDocumentInNewTab": "selectedDocumentInNewTab"; }, never, ["*"], false, never>;
174
162
  }
@@ -1,9 +1,11 @@
1
1
  import { OnChanges, SimpleChanges, OnInit } from '@angular/core';
2
2
  import { ExcelParserService, ExcelRowData } from '../../services/excel-parser.service';
3
3
  import { CsvParserService, CsvRowData } from '../../services/csv-parser.service';
4
+ import { EmlParserService, ParsedEmailData } from '../../services/eml-parser.service';
4
5
  import { DocumentHttpService } from '../../services/document-http.service';
5
6
  import { DocumentZoomService } from '../../services/document-zoom.service';
6
7
  import { DocumentListItem } from '../../models/document-list-response.model';
8
+ import { DomSanitizer } from '@angular/platform-browser';
7
9
  import * as i0 from "@angular/core";
8
10
  /**
9
11
  * Component for viewing different types of document content.
@@ -14,8 +16,10 @@ import * as i0 from "@angular/core";
14
16
  export declare class DocumentContentViewerComponent implements OnChanges, OnInit {
15
17
  private excelParserService;
16
18
  private csvParserService;
19
+ private emlParserService;
17
20
  private documentHttpService;
18
21
  private zoomService;
22
+ private sanitizer;
19
23
  /**
20
24
  * The document URL to display
21
25
  * @type {string}
@@ -116,13 +120,31 @@ export declare class DocumentContentViewerComponent implements OnChanges, OnInit
116
120
  * @type {number}
117
121
  */
118
122
  currentZoom: number;
123
+ /**
124
+ * Email data for display
125
+ * @type {ParsedEmailData | null}
126
+ */
127
+ emailData: ParsedEmailData | null;
128
+ /**
129
+ * Loading state for Email files
130
+ * @type {boolean}
131
+ */
132
+ isLoadingEmail: boolean;
133
+ /**
134
+ * Error state for Email files
135
+ * @type {string | null}
136
+ */
137
+ emailError: string | null;
119
138
  /**
120
139
  * Constructor
121
140
  * @param {ExcelParserService} excelParserService - Service for parsing Excel files
122
- * @param {DocumentHttpService} documentHttpService - Service for making HTTP requests with authentication
141
+ * @param {CsvParserService} csvParserService - Service for parsing CSV files
142
+ * @param {EmlParserService} emlParserService - Service for parsing EML files
143
+ * @param {DocumentHttpService} documentHttpService - Service for making HTTP requests for Excel/CSV files
123
144
  * @param {DocumentZoomService} zoomService - Service for handling zoom functionality
145
+ * @param {DomSanitizer} sanitizer - Service for sanitizing HTML content
124
146
  */
125
- constructor(excelParserService: ExcelParserService, csvParserService: CsvParserService, documentHttpService: DocumentHttpService, zoomService: DocumentZoomService);
147
+ constructor(excelParserService: ExcelParserService, csvParserService: CsvParserService, emlParserService: EmlParserService, documentHttpService: DocumentHttpService, zoomService: DocumentZoomService, sanitizer: DomSanitizer);
126
148
  /**
127
149
  * Computed property to determine if the document is a PDF
128
150
  * @type {boolean}
@@ -256,6 +278,14 @@ export declare class DocumentContentViewerComponent implements OnChanges, OnInit
256
278
  private isCsvDataValid;
257
279
  private getFileExtension;
258
280
  get isImage(): boolean;
281
+ /**
282
+ * Loads Email data for display
283
+ */
284
+ private loadEmailData;
285
+ /**
286
+ * Resets Email data to initial state
287
+ */
288
+ private resetEmailData;
259
289
  static ɵfac: i0.ɵɵFactoryDeclaration<DocumentContentViewerComponent, never>;
260
290
  static ɵcmp: i0.ɵɵComponentDeclaration<DocumentContentViewerComponent, "document-content-viewer", never, { "documentUrl": { "alias": "documentUrl"; "required": false; }; "contentType": { "alias": "contentType"; "required": false; }; "documentName": { "alias": "documentName"; "required": false; }; "selectedDocument": { "alias": "selectedDocument"; "required": false; }; "contextId": { "alias": "contextId"; "required": false; }; "isFormHide": { "alias": "isFormHide"; "required": false; }; }, {}, never, never, false, never>;
261
291
  }
@@ -57,6 +57,11 @@ export declare class DocumentListComponent implements OnInit, OnDestroy, OnChang
57
57
  * Subscription to document list response from store
58
58
  */
59
59
  private documentListSubscription;
60
+ handleSelectedDocumentInNewTab: EventEmitter<{
61
+ selectedDocument: DocumentListItem;
62
+ contextId: string;
63
+ documentList: DocumentListItem[];
64
+ }>;
60
65
  /**
61
66
  * The currently selected document.
62
67
  * @type {DocumentModel}
@@ -126,11 +131,6 @@ export declare class DocumentListComponent implements OnInit, OnDestroy, OnChang
126
131
  * Message to display for document deletion
127
132
  */
128
133
  deleteMessage: Message[];
129
- handleSelectedDocumentInNewTab: EventEmitter<{
130
- selectedDocument: DocumentListItem;
131
- contextId: string;
132
- documentList: DocumentListItem[];
133
- }>;
134
134
  handleSelectedDocument: EventEmitter<DocumentListItem>;
135
135
  /**
136
136
  * Getter to return category labels as they come from the API
@@ -181,11 +181,6 @@ export declare class DocumentListComponent implements OnInit, OnDestroy, OnChang
181
181
  * @param {any} rowData - The row data containing the document to delete
182
182
  */
183
183
  handleDeleteAction(rowData: any): void;
184
- /**
185
- * Handles table row ctrl click event
186
- * @param {any} rowData - The row data containing the document to open in a new tab
187
- */
188
- handleTableRowCtrlClick(rowData: any): void;
189
184
  /**
190
185
  * Closes the document viewer dialog and resets the selected document
191
186
  */
@@ -195,6 +190,7 @@ export declare class DocumentListComponent implements OnInit, OnDestroy, OnChang
195
190
  * @param {boolean} isDeleteAction - Optional flag indicating if this refresh is due to a delete action
196
191
  */
197
192
  refreshDocumentList(isDeleteAction?: boolean): void;
193
+ handleTableRowCtrlClick(rowData: any): void;
198
194
  /**
199
195
  * Handles document status update events from viewer
200
196
  * @param event - The status update event
@@ -84,8 +84,8 @@ export declare class DocumentHttpService {
84
84
  /**
85
85
  * Fetches document status count data by application ID with optional context ID and category parameters.
86
86
  * @param {string} applicationId - The application ID to fetch status data.
87
- * @param {string | null} contextId - The context ID (applicant ID) to filter by. If null, uses applicationId.
88
- * @param {string | null} categoryId - The category ID to filter by.
87
+ * @param {string | null} contextId - The context ID (applicant ID) to filter by. If null, omitted from query.
88
+ * @param {string | null} categoryId - The category ID to filter by. If null, omitted from query.
89
89
  * @returns {Observable<StatusDataModel[]>} Observable that emits the status data.
90
90
  */
91
91
  getStatusDocumentCount(applicationId: string, contextId?: string | null, categoryId?: string | null): Observable<StatusDataModel[]>;
@@ -161,6 +161,12 @@ export declare class DocumentHttpService {
161
161
  * @returns {Observable<string>} Observable that emits the file data as string
162
162
  */
163
163
  downloadCsvFile(documentUrl: string): Observable<string>;
164
+ /**
165
+ * Downloads an email file (EML) with appropriate handling for different storage types
166
+ * @param documentUrl - URL of the email file
167
+ * @returns Observable of file content as text
168
+ */
169
+ downloadEmailFile(documentUrl: string): Observable<string>;
164
170
  static ɵfac: i0.ɵɵFactoryDeclaration<DocumentHttpService, never>;
165
171
  static ɵprov: i0.ɵɵInjectableDeclaration<DocumentHttpService>;
166
172
  }
@@ -0,0 +1,116 @@
1
+ import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
2
+ import { Observable } from 'rxjs';
3
+ import { HttpClient } from '@angular/common/http';
4
+ import * as i0 from "@angular/core";
5
+ /**
6
+ * Interface for parsed email data
7
+ */
8
+ export interface ParsedEmailData {
9
+ from: string;
10
+ to: string;
11
+ cc?: string;
12
+ subject: string;
13
+ date: string;
14
+ body: string;
15
+ isHtml: boolean;
16
+ attachments?: EmailAttachment[];
17
+ }
18
+ /**
19
+ * Interface for email attachments
20
+ */
21
+ export interface EmailAttachment {
22
+ filename: string;
23
+ contentType: string;
24
+ size: number;
25
+ }
26
+ /**
27
+ * Service for parsing EML (email message) files
28
+ * Handles both plain text and HTML email content
29
+ */
30
+ export declare class EmlParserService {
31
+ private sanitizer;
32
+ private http;
33
+ constructor(sanitizer: DomSanitizer, http: HttpClient);
34
+ /**
35
+ * Parses EML file content
36
+ * @param emlContent - Raw EML file content as string
37
+ * @returns Parsed email data
38
+ */
39
+ parseEmlData(emlContent: string): ParsedEmailData | null;
40
+ /**
41
+ * Parses email headers from EML content
42
+ * @param lines - Lines of the EML file
43
+ * @returns Object containing parsed headers
44
+ */
45
+ private parseHeaders;
46
+ /**
47
+ * Parses the email body from EML content
48
+ * @param lines - Lines of the EML file
49
+ * @returns Object containing body content and format information
50
+ */
51
+ private parseBody;
52
+ /**
53
+ * Extracts body from multipart email
54
+ * @param content - Email content
55
+ * @param boundary - Multipart boundary string
56
+ * @param preferredType - Preferred content type
57
+ * @returns Array of body lines
58
+ */
59
+ private extractMultipartBody;
60
+ /**
61
+ * Decodes quoted-printable encoded content
62
+ * @param content - Quoted-printable encoded string
63
+ * @returns Decoded string
64
+ */
65
+ private decodeQuotedPrintable;
66
+ /**
67
+ * Sanitizes HTML content for safe display
68
+ * @param html - Raw HTML content
69
+ * @returns Sanitized HTML
70
+ */
71
+ private sanitizeHtmlContent;
72
+ /**
73
+ * Parses attachment information from EML content
74
+ * @param emlContent - Raw EML content
75
+ * @returns Array of attachment information
76
+ */
77
+ private parseAttachments;
78
+ /**
79
+ * Cleans and formats email addresses
80
+ * @param email - Raw email address string
81
+ * @returns Cleaned email address
82
+ */
83
+ private cleanEmailAddress;
84
+ /**
85
+ * Decodes encoded email headers (RFC 2047)
86
+ * @param header - Encoded header string
87
+ * @returns Decoded header string
88
+ */
89
+ private decodeHeader;
90
+ /**
91
+ * Formats email date to readable format
92
+ * @param dateStr - Raw date string from email
93
+ * @returns Formatted date string
94
+ */
95
+ private formatDate;
96
+ /**
97
+ * Sanitizes HTML for Angular display
98
+ * @param html - HTML string
99
+ * @returns SafeHtml for Angular templates
100
+ */
101
+ getSafeHtml(html: string): SafeHtml;
102
+ /**
103
+ * Downloads and parses an EML file from a URL
104
+ * @param documentUrl - URL of the EML file
105
+ * @returns Observable of parsed email data
106
+ */
107
+ loadAndParseEmail(documentUrl: string): Observable<ParsedEmailData>;
108
+ /**
109
+ * Downloads an email file with appropriate authentication handling
110
+ * @param documentUrl - URL of the email file
111
+ * @returns Observable of file content as text
112
+ */
113
+ private downloadEmailFile;
114
+ static ɵfac: i0.ɵɵFactoryDeclaration<EmlParserService, never>;
115
+ static ɵprov: i0.ɵɵInjectableDeclaration<EmlParserService>;
116
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cat-documents-ng",
3
- "version": "0.4.02",
3
+ "version": "0.4.04",
4
4
  "peerDependencies": {
5
5
  "@angular/common": "^19.0.0",
6
6
  "@angular/core": "^19.0.0"
package/public-api.d.ts CHANGED
@@ -14,6 +14,9 @@ export * from './lib/document/models/uploaded-file-response.model';
14
14
  export * from './lib/document/services/document-table-builder.service';
15
15
  export * from './lib/document/services/document-content-type.service';
16
16
  export * from './lib/document/services/document-zoom.service';
17
+ export * from './lib/document/services/eml-parser.service';
18
+ export * from './lib/document/services/excel-parser.service';
19
+ export * from './lib/document/services/csv-parser.service';
17
20
  export * from './lib/document/directives/document.directive';
18
21
  export * from './lib/document/directives/permission.directive';
19
22
  export * from './Shared/components/confirmation-dialog/confirmation-dialog.component';