@smartsides/oracle-ebs-sdk 1.0.7 → 1.0.9

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.
package/README.md CHANGED
@@ -5,7 +5,8 @@ TypeScript SDK for Oracle EBS API - Optimized for Next.js 15+
5
5
  ## Features
6
6
 
7
7
  - ✅ **Full TypeScript Support** - Complete type safety with autocomplete
8
- - ✅ **All API Endpoints** - 9 modules covering all Oracle EBS functionality
8
+ - ✅ **All API Endpoints** - 10 modules covering all Oracle EBS functionality
9
+ - ✅ **AI Assistant** - ChatGPT-style chat with voice support ⭐ NEW
9
10
  - ✅ **Auto User Context** - Stores full user object from login automatically
10
11
  - ✅ **Smart Defaults** - Employee number auto-extracted for payslip/leave requests
11
12
  - ✅ **Error Handling** - Typed errors with automatic retry logic
@@ -181,19 +182,48 @@ const result = await client.sitRequests.submit(data);
181
182
  ### Notifications
182
183
 
183
184
  ```typescript
184
- // Get notifications
185
+ // Get notification list (USER_ID auto-extracted from login)
185
186
  const notifications = await client.notifications.getList();
186
187
 
187
- // Get details
188
- const details = await client.notifications.getDetails({ notificationId: '123' });
188
+ // Get notification details
189
+ const details = await client.notifications.getDetails({
190
+ notificationId: '9341634'
191
+ });
192
+
193
+ // Get all details (SSHR_SIT_REQDTLS)
194
+ const allDetails = await client.notifications.getAllDetails({
195
+ notificationId: '9288875',
196
+ itemKey: '756840',
197
+ analysisCriteriaId: '3643761',
198
+ idFlexNum: '50310'
199
+ });
200
+
201
+ // Get absence details (for FYI notifications)
202
+ const absenceDetails = await client.notifications.getAbsenceDetails({
203
+ itemKey: '760206'
204
+ });
205
+
206
+ // Get action history
207
+ const history = await client.notifications.getActionHistory({
208
+ notificationId: '9330566'
209
+ });
189
210
 
190
- // Process approval
211
+ // Process approval (APPROVE or DECLINE)
191
212
  await client.notifications.processApproval({
192
- notificationId: '123',
213
+ notificationId: '9341634',
193
214
  action: 'APPROVE',
215
+ comments: 'Approved for processing',
216
+ responderUserName: 'optional'
217
+ });
218
+
219
+ // Close FYI notification (USER_ID auto-extracted)
220
+ await client.notifications.closeFyi({
221
+ notificationId: '9336582'
194
222
  });
195
223
  ```
196
224
 
225
+ **Auto User ID**: Notification methods automatically use USER_ID from the logged-in user where needed.
226
+
197
227
  ### Payslip
198
228
 
199
229
  ```typescript
@@ -264,6 +294,101 @@ const health = await client.health.check();
264
294
  const message = await client.health.ping();
265
295
  ```
266
296
 
297
+ ### AI Assistant 🆕
298
+
299
+ The AI module provides ChatGPT-style conversational AI with persistent chat history.
300
+
301
+ ```typescript
302
+ import { MessageRole } from '@smartsides/oracle-ebs-sdk';
303
+
304
+ // Send a chat message
305
+ const response = await client.ai.sendMessage({
306
+ message: 'Show my latest payslip',
307
+ language: 'en',
308
+ history: [
309
+ { role: MessageRole.USER, content: 'Hello' },
310
+ { role: MessageRole.ASSISTANT, content: 'Hi! How can I help?' }
311
+ ],
312
+ threadId: 'optional-thread-id' // For continuing existing conversation
313
+ });
314
+
315
+ // Response includes:
316
+ // - message: AI response text
317
+ // - ctas: Call-to-action buttons (if any)
318
+ // - metadata: Intent, tokens used, etc.
319
+ // - threadId: Thread ID for conversation persistence
320
+
321
+ // Voice message with thread continuity ⭐ NEW
322
+ // First voice message - creates new thread
323
+ const voiceResponse1 = await client.ai.sendVoice(audioBlob, {
324
+ language: 'en'
325
+ });
326
+ const threadId = voiceResponse1.response.threadId;
327
+
328
+ // Second voice message - continues same thread
329
+ const voiceResponse2 = await client.ai.sendVoice(audioBlob, {
330
+ language: 'en',
331
+ threadId: threadId // Maintains conversation context!
332
+ });
333
+
334
+ // Arabic voice with thread continuity
335
+ const arabicResponse = await client.ai.sendVoice(audioBlob, {
336
+ language: 'ar',
337
+ threadId: threadId // Works with Arabic too!
338
+ });
339
+
340
+ // Thread management
341
+ const threads = await client.ai.getChatThreads();
342
+ const messages = await client.ai.getThreadMessages(threadId);
343
+ await client.ai.deleteThread(threadId);
344
+ ```
345
+
346
+ **Voice Thread Continuity Benefits:**
347
+ - ✅ Multi-turn voice conversations (request → confirmation → submission)
348
+ - ✅ Maintains full conversation context across voice messages
349
+ - ✅ Works with both English and Arabic
350
+ - ✅ Automatic leave type mapping and date extraction
351
+ - ✅ Seamless voice-based leave request submission
352
+
353
+ // Transcribe voice to text
354
+ const transcription = await client.ai.transcribeVoice(audioBlob);
355
+
356
+ // Get all chat threads for current user
357
+ const threads = await client.ai.getChatThreads();
358
+ // Returns: Array of ChatThread objects with id, title, messageCount, etc.
359
+
360
+ // Get messages for a specific thread
361
+ const { thread, messages } = await client.ai.getThreadMessages(threadId);
362
+ // Returns: Thread metadata + array of ThreadMessage objects
363
+
364
+ // Create a new chat thread
365
+ const newThread = await client.ai.createThread();
366
+ // Returns: ChatThread object with new thread ID
367
+
368
+ // Delete a chat thread
369
+ await client.ai.deleteThread(threadId);
370
+ // Deletes thread and all associated messages
371
+ ```
372
+
373
+ **Chat History Features:**
374
+ - ✅ **Persistent Threads**: All conversations saved to PostgreSQL
375
+ - ✅ **Auto-Title Generation**: Thread titles generated from first message
376
+ - ✅ **Message History**: Complete conversation history with timestamps
377
+ - ✅ **User-Scoped**: Each user only sees their own threads
378
+ - ✅ **Secure**: JWT authentication + ownership validation
379
+
380
+ **Available Types:**
381
+ ```typescript
382
+ import {
383
+ MessageRole, // USER | ASSISTANT
384
+ ActionType, // Enum for action types
385
+ UserIntent, // Enum for user intents
386
+ ChatThread, // Thread metadata type
387
+ ThreadMessage, // Message type
388
+ CallToAction, // CTA button type
389
+ } from '@smartsides/oracle-ebs-sdk';
390
+ ```
391
+
267
392
  ## Error Handling
268
393
 
269
394
  ```typescript
@@ -311,6 +436,69 @@ const client = new OracleEBSClient({
311
436
  });
312
437
  ```
313
438
 
439
+ ## 🔒 Security Best Practices
440
+
441
+ ### CRITICAL: Never Decode JWT Tokens
442
+
443
+ **❌ NEVER do this in your application:**
444
+
445
+ ```typescript
446
+ // DON'T decode JWT on the client side
447
+ const token = localStorage.getItem('token');
448
+ const payload = JSON.parse(atob(token.split('.')[1]));
449
+ const employeeNumber = payload.EMPLOYEE_NUMBER;
450
+
451
+ // DON'T pass user context to SDK methods
452
+ await client.payslip.getHeader({ periodName, employeeNumber });
453
+ ```
454
+
455
+ **✅ ALWAYS do this instead:**
456
+
457
+ ```typescript
458
+ // Just set the token and pass business parameters
459
+ client.setToken(token);
460
+ await client.payslip.getHeader({ periodName });
461
+ // Backend extracts employeeNumber from JWT automatically
462
+ ```
463
+
464
+ ### Why This Matters
465
+
466
+ 1. **Security**: JWT payload is base64 encoded, NOT encrypted - anyone can read it
467
+ 2. **Single Source of Truth**: Backend validates and extracts user context
468
+ 3. **Prevents Tampering**: Users cannot access other users' data
469
+ 4. **Maintainability**: JWT structure changes don't affect your code
470
+ 5. **Consistency**: All endpoints follow the same pattern
471
+
472
+ ### How It Works
473
+
474
+ The SDK sends the JWT token in the Authorization header. The backend:
475
+ 1. Validates the token signature
476
+ 2. Checks token expiration
477
+ 3. Extracts user context (employeeNumber, userId, personId, etc.)
478
+ 4. Uses this context to fetch user-specific data
479
+
480
+ ### Affected Methods
481
+
482
+ All user-specific methods automatically use JWT context:
483
+ - ✅ `payslip.getHeader()` - Uses EMPLOYEE_NUMBER from JWT
484
+ - ✅ `payslip.getDetails()` - Uses EMPLOYEE_NUMBER from JWT
485
+ - ✅ `leaves.getRestrictedTypes()` - Uses USER_ID, PERSON_ID from JWT
486
+ - ✅ `leaves.createRequest()` - Uses PERSON_ID, USER_ID from JWT
487
+ - ✅ `notifications.getList()` - Uses USER_ID from JWT
488
+ - ✅ `notifications.closeFyi()` - Uses USER_ID from JWT
489
+ - ✅ `employee.getPersonalInfo()` - Uses context from JWT
490
+ - ✅ `accrualBalances.getBalances()` - Uses context from JWT
491
+
492
+ **You only pass business parameters** (periodName, dates, etc.) - never user context.
493
+
494
+ ### Reference
495
+
496
+ For complete security documentation, see:
497
+ - [Backend JWT Security Pattern](../docs/JWT_SECURITY_PATTERN.md)
498
+ - [Backend Documentation](../docs/index.md#-core-security-principles)
499
+
500
+ ---
501
+
314
502
  ## React Query Hooks
315
503
 
316
504
  All hooks are available from `@smartsides/oracle-ebs-sdk/hooks`:
@@ -216,6 +216,8 @@ interface SubmitSitRequestResponse {
216
216
  itemKey: string;
217
217
  }
218
218
  interface GetSitHistoryParams {
219
+ sitName: string;
220
+ transactionId?: string;
219
221
  startDate?: string;
220
222
  endDate?: string;
221
223
  }
@@ -234,7 +236,7 @@ declare class SitRequestsModule extends BaseClient {
234
236
  getSegments(params: GetSitSegmentsParams): Promise<GetSitSegmentsResponse>;
235
237
  saveAndPreview(input: SaveAndPreviewSitRequestInput): Promise<SaveAndPreviewSitRequestResponse>;
236
238
  submit(input: SubmitSitRequestInput): Promise<SubmitSitRequestResponse>;
237
- getHistory(params?: GetSitHistoryParams): Promise<GetSitHistoryResponse>;
239
+ getHistory(params: GetSitHistoryParams): Promise<GetSitHistoryResponse>;
238
240
  }
239
241
 
240
242
  interface Notification {
@@ -448,7 +450,6 @@ interface GetPayslipRunBalancesResponse {
448
450
  }
449
451
 
450
452
  declare class PayslipModule extends BaseClient {
451
- private getEmployeeNumberFromContext;
452
453
  getHeader(params: GetPayslipHeaderParams): Promise<PayslipHeader>;
453
454
  getDetails(params: GetPayslipDetailsParams): Promise<GetPayslipDetailsResponse>;
454
455
  getLeaveDetails(params: GetPayslipLeaveDetailsParams): Promise<GetPayslipLeaveDetailsResponse>;
@@ -559,6 +560,142 @@ declare class HealthModule extends BaseClient {
559
560
  ping(): Promise<string>;
560
561
  }
561
562
 
563
+ declare enum MessageRole {
564
+ USER = "user",
565
+ ASSISTANT = "assistant",
566
+ SYSTEM = "system"
567
+ }
568
+ declare enum ActionType {
569
+ NAVIGATE = "navigate",
570
+ API_CALL = "api_call",
571
+ DOWNLOAD = "download",
572
+ CLOSE_NOTIFICATION = "close_notification",
573
+ SUBMIT_LEAVE = "submit_leave",
574
+ APPROVE_NOTIFICATION = "approve_notification",
575
+ DECLINE_NOTIFICATION = "decline_notification"
576
+ }
577
+ declare enum UserIntent {
578
+ NOTIFICATIONS_SUMMARY = "notifications_summary",
579
+ NOTIFICATION_CLOSE = "notification_close",
580
+ NOTIFICATION_ACTION = "notification_action",
581
+ PAYSLIP_QUERY = "payslip_query",
582
+ PAYSLIP_RETRIEVAL = "payslip_retrieval",
583
+ SALARY_DEDUCTION = "salary_deduction",
584
+ LEAVE_BALANCE = "leave_balance",
585
+ LEAVE_REQUEST = "leave_request",
586
+ PROFILE_INFO = "profile_info",
587
+ HIRING_DATE = "hiring_date",
588
+ POSITION_INFO = "position_info",
589
+ GENERAL_QUERY = "general_query",
590
+ OUT_OF_SCOPE = "out_of_scope"
591
+ }
592
+ interface ChatMessage {
593
+ role: MessageRole;
594
+ content: string;
595
+ }
596
+ interface CallToAction {
597
+ id: string;
598
+ label: string;
599
+ type: ActionType;
600
+ params?: Record<string, any>;
601
+ path?: string;
602
+ icon?: string;
603
+ variant?: 'default' | 'outline' | 'ghost' | 'destructive';
604
+ }
605
+ interface AiResponse {
606
+ message: string;
607
+ ctas?: CallToAction[];
608
+ metadata?: {
609
+ intent?: UserIntent;
610
+ model?: string;
611
+ tokensUsed?: number;
612
+ [key: string]: any;
613
+ };
614
+ requiresAction?: boolean;
615
+ chartData?: any;
616
+ threadId?: string;
617
+ }
618
+ interface ChatRequest {
619
+ message: string;
620
+ language?: 'en' | 'ar';
621
+ history?: ChatMessage[];
622
+ threadId?: string;
623
+ }
624
+ interface VoiceTranscription {
625
+ text: string;
626
+ language: string;
627
+ confidence?: number;
628
+ duration?: number;
629
+ }
630
+ interface VoiceResponse {
631
+ transcription: VoiceTranscription;
632
+ response: AiResponse;
633
+ }
634
+ interface ChatHistory {
635
+ id: string;
636
+ messages: Array<ChatMessage & {
637
+ timestamp: Date;
638
+ }>;
639
+ createdAt: Date;
640
+ updatedAt: Date;
641
+ }
642
+ interface ChatThread {
643
+ id: string;
644
+ userId: string;
645
+ username: string;
646
+ title: string | null;
647
+ status: string;
648
+ intent: string | null;
649
+ createdAt: Date;
650
+ updatedAt: Date;
651
+ lastMessageAt: Date;
652
+ messageCount: number;
653
+ }
654
+ interface ThreadMessage {
655
+ id: string;
656
+ threadId: string;
657
+ role: 'user' | 'assistant';
658
+ content: string;
659
+ metadata?: {
660
+ intent?: string;
661
+ ctas?: CallToAction[];
662
+ tokensUsed?: number;
663
+ [key: string]: any;
664
+ };
665
+ createdAt: Date;
666
+ }
667
+ interface GetThreadMessagesResponse {
668
+ thread: ChatThread;
669
+ messages: ThreadMessage[];
670
+ }
671
+ interface GetThreadsResponse {
672
+ threads: ChatThread[];
673
+ }
674
+ interface CreateThreadResponse {
675
+ thread: ChatThread;
676
+ }
677
+ interface DeleteThreadResponse {
678
+ success: boolean;
679
+ message: string;
680
+ }
681
+
682
+ declare class AiModule extends BaseClient {
683
+ sendMessage(request: ChatRequest): Promise<AiResponse>;
684
+ sendVoice(audioBlob: Blob, options?: {
685
+ language?: 'en' | 'ar';
686
+ threadId?: string;
687
+ }): Promise<VoiceResponse>;
688
+ saveChatMessage(message: ChatMessage): void;
689
+ getLocalChatHistory(): Array<ChatMessage & {
690
+ timestamp: Date;
691
+ }>;
692
+ clearChatHistory(): void;
693
+ getChatThreads(): Promise<ChatThread[]>;
694
+ getThreadMessages(threadId: string): Promise<GetThreadMessagesResponse>;
695
+ createThread(): Promise<ChatThread>;
696
+ deleteThread(threadId: string): Promise<void>;
697
+ }
698
+
562
699
  declare class OracleEBSClient {
563
700
  readonly auth: AuthModule;
564
701
  readonly leaves: LeavesModule;
@@ -569,6 +706,7 @@ declare class OracleEBSClient {
569
706
  readonly accrualBalances: AccrualBalancesModule;
570
707
  readonly forms: FormsModule;
571
708
  readonly health: HealthModule;
709
+ readonly ai: AiModule;
572
710
  constructor(config: OracleEBSConfig);
573
711
  setToken(token: string, user?: {
574
712
  userName?: string;
@@ -581,4 +719,4 @@ declare class OracleEBSClient {
581
719
  clearToken(): void;
582
720
  }
583
721
 
584
- export { type APIResponse as A, type GetPayslipDetailsParams as B, type CacheOptions as C, type PayslipDetail as D, type GetPayslipDetailsResponse as E, type PersonalInformation as F, type GetAbsenceTypesParams as G, type EmployeeHierarchyNode as H, type GetEmployeeHierarchyResponse as I, type GetTableColumnsParams as J, type GetTableColumnsResponse as K, type LoginCredentials as L, type DffSegment as M, type Notification as N, OracleEBSClient as O, type ProcessApprovalInput as P, type GetDffSegmentsParams as Q, type RetryOptions as R, type SitSegment as S, type TableColumn as T, type UserContext as U, type GetDffSegmentsResponse as V, type HealthCheckResponse as W, type AccrualBalance as X, type GetAccrualBalancesParams as Y, type GetAccrualBalancesResponse as Z, type OracleEBSConfig as a, type LoginResponse as b, type Responsibility as c, type AbsenceType as d, type GetAbsenceTypesResponse as e, type LeaveHistoryRecord as f, type GetLeaveHistoryResponse as g, type CreateLeaveRequestInput as h, type CreateLeaveRequestResponse as i, type GetSitSegmentsParams as j, type GetSitSegmentsResponse as k, type SaveAndPreviewSitRequestInput as l, type SaveAndPreviewSitRequestResponse as m, type SubmitSitRequestInput as n, type SubmitSitRequestResponse as o, type GetSitHistoryParams as p, type SitHistoryRecord as q, type GetSitHistoryResponse as r, type GetNotificationsResponse as s, type NotificationDetails as t, type GetNotificationDetailsParams as u, type ProcessApprovalResponse as v, type CloseFyiParams as w, type CloseFyiResponse as x, type GetPayslipHeaderParams as y, type PayslipHeader as z };
722
+ export { ActionType as $, type APIResponse as A, type GetPayslipDetailsParams as B, type CacheOptions as C, type PayslipDetail as D, type GetPayslipDetailsResponse as E, type PersonalInformation as F, type GetAbsenceTypesParams as G, type EmployeeHierarchyNode as H, type GetEmployeeHierarchyResponse as I, type GetTableColumnsParams as J, type GetTableColumnsResponse as K, type LoginCredentials as L, type DffSegment as M, type Notification as N, OracleEBSClient as O, type ProcessApprovalInput as P, type GetDffSegmentsParams as Q, type RetryOptions as R, type SitSegment as S, type TableColumn as T, type UserContext as U, type GetDffSegmentsResponse as V, type HealthCheckResponse as W, type AccrualBalance as X, type GetAccrualBalancesParams as Y, type GetAccrualBalancesResponse as Z, MessageRole as _, type OracleEBSConfig as a, UserIntent as a0, type ChatMessage as a1, type CallToAction as a2, type AiResponse as a3, type ChatRequest as a4, type VoiceTranscription as a5, type VoiceResponse as a6, type ChatHistory as a7, type ChatThread as a8, type ThreadMessage as a9, type GetThreadMessagesResponse as aa, type GetThreadsResponse as ab, type CreateThreadResponse as ac, type DeleteThreadResponse as ad, type LoginResponse as b, type Responsibility as c, type AbsenceType as d, type GetAbsenceTypesResponse as e, type LeaveHistoryRecord as f, type GetLeaveHistoryResponse as g, type CreateLeaveRequestInput as h, type CreateLeaveRequestResponse as i, type GetSitSegmentsParams as j, type GetSitSegmentsResponse as k, type SaveAndPreviewSitRequestInput as l, type SaveAndPreviewSitRequestResponse as m, type SubmitSitRequestInput as n, type SubmitSitRequestResponse as o, type GetSitHistoryParams as p, type SitHistoryRecord as q, type GetSitHistoryResponse as r, type GetNotificationsResponse as s, type NotificationDetails as t, type GetNotificationDetailsParams as u, type ProcessApprovalResponse as v, type CloseFyiParams as w, type CloseFyiResponse as x, type GetPayslipHeaderParams as y, type PayslipHeader as z };
@@ -216,6 +216,8 @@ interface SubmitSitRequestResponse {
216
216
  itemKey: string;
217
217
  }
218
218
  interface GetSitHistoryParams {
219
+ sitName: string;
220
+ transactionId?: string;
219
221
  startDate?: string;
220
222
  endDate?: string;
221
223
  }
@@ -234,7 +236,7 @@ declare class SitRequestsModule extends BaseClient {
234
236
  getSegments(params: GetSitSegmentsParams): Promise<GetSitSegmentsResponse>;
235
237
  saveAndPreview(input: SaveAndPreviewSitRequestInput): Promise<SaveAndPreviewSitRequestResponse>;
236
238
  submit(input: SubmitSitRequestInput): Promise<SubmitSitRequestResponse>;
237
- getHistory(params?: GetSitHistoryParams): Promise<GetSitHistoryResponse>;
239
+ getHistory(params: GetSitHistoryParams): Promise<GetSitHistoryResponse>;
238
240
  }
239
241
 
240
242
  interface Notification {
@@ -448,7 +450,6 @@ interface GetPayslipRunBalancesResponse {
448
450
  }
449
451
 
450
452
  declare class PayslipModule extends BaseClient {
451
- private getEmployeeNumberFromContext;
452
453
  getHeader(params: GetPayslipHeaderParams): Promise<PayslipHeader>;
453
454
  getDetails(params: GetPayslipDetailsParams): Promise<GetPayslipDetailsResponse>;
454
455
  getLeaveDetails(params: GetPayslipLeaveDetailsParams): Promise<GetPayslipLeaveDetailsResponse>;
@@ -559,6 +560,142 @@ declare class HealthModule extends BaseClient {
559
560
  ping(): Promise<string>;
560
561
  }
561
562
 
563
+ declare enum MessageRole {
564
+ USER = "user",
565
+ ASSISTANT = "assistant",
566
+ SYSTEM = "system"
567
+ }
568
+ declare enum ActionType {
569
+ NAVIGATE = "navigate",
570
+ API_CALL = "api_call",
571
+ DOWNLOAD = "download",
572
+ CLOSE_NOTIFICATION = "close_notification",
573
+ SUBMIT_LEAVE = "submit_leave",
574
+ APPROVE_NOTIFICATION = "approve_notification",
575
+ DECLINE_NOTIFICATION = "decline_notification"
576
+ }
577
+ declare enum UserIntent {
578
+ NOTIFICATIONS_SUMMARY = "notifications_summary",
579
+ NOTIFICATION_CLOSE = "notification_close",
580
+ NOTIFICATION_ACTION = "notification_action",
581
+ PAYSLIP_QUERY = "payslip_query",
582
+ PAYSLIP_RETRIEVAL = "payslip_retrieval",
583
+ SALARY_DEDUCTION = "salary_deduction",
584
+ LEAVE_BALANCE = "leave_balance",
585
+ LEAVE_REQUEST = "leave_request",
586
+ PROFILE_INFO = "profile_info",
587
+ HIRING_DATE = "hiring_date",
588
+ POSITION_INFO = "position_info",
589
+ GENERAL_QUERY = "general_query",
590
+ OUT_OF_SCOPE = "out_of_scope"
591
+ }
592
+ interface ChatMessage {
593
+ role: MessageRole;
594
+ content: string;
595
+ }
596
+ interface CallToAction {
597
+ id: string;
598
+ label: string;
599
+ type: ActionType;
600
+ params?: Record<string, any>;
601
+ path?: string;
602
+ icon?: string;
603
+ variant?: 'default' | 'outline' | 'ghost' | 'destructive';
604
+ }
605
+ interface AiResponse {
606
+ message: string;
607
+ ctas?: CallToAction[];
608
+ metadata?: {
609
+ intent?: UserIntent;
610
+ model?: string;
611
+ tokensUsed?: number;
612
+ [key: string]: any;
613
+ };
614
+ requiresAction?: boolean;
615
+ chartData?: any;
616
+ threadId?: string;
617
+ }
618
+ interface ChatRequest {
619
+ message: string;
620
+ language?: 'en' | 'ar';
621
+ history?: ChatMessage[];
622
+ threadId?: string;
623
+ }
624
+ interface VoiceTranscription {
625
+ text: string;
626
+ language: string;
627
+ confidence?: number;
628
+ duration?: number;
629
+ }
630
+ interface VoiceResponse {
631
+ transcription: VoiceTranscription;
632
+ response: AiResponse;
633
+ }
634
+ interface ChatHistory {
635
+ id: string;
636
+ messages: Array<ChatMessage & {
637
+ timestamp: Date;
638
+ }>;
639
+ createdAt: Date;
640
+ updatedAt: Date;
641
+ }
642
+ interface ChatThread {
643
+ id: string;
644
+ userId: string;
645
+ username: string;
646
+ title: string | null;
647
+ status: string;
648
+ intent: string | null;
649
+ createdAt: Date;
650
+ updatedAt: Date;
651
+ lastMessageAt: Date;
652
+ messageCount: number;
653
+ }
654
+ interface ThreadMessage {
655
+ id: string;
656
+ threadId: string;
657
+ role: 'user' | 'assistant';
658
+ content: string;
659
+ metadata?: {
660
+ intent?: string;
661
+ ctas?: CallToAction[];
662
+ tokensUsed?: number;
663
+ [key: string]: any;
664
+ };
665
+ createdAt: Date;
666
+ }
667
+ interface GetThreadMessagesResponse {
668
+ thread: ChatThread;
669
+ messages: ThreadMessage[];
670
+ }
671
+ interface GetThreadsResponse {
672
+ threads: ChatThread[];
673
+ }
674
+ interface CreateThreadResponse {
675
+ thread: ChatThread;
676
+ }
677
+ interface DeleteThreadResponse {
678
+ success: boolean;
679
+ message: string;
680
+ }
681
+
682
+ declare class AiModule extends BaseClient {
683
+ sendMessage(request: ChatRequest): Promise<AiResponse>;
684
+ sendVoice(audioBlob: Blob, options?: {
685
+ language?: 'en' | 'ar';
686
+ threadId?: string;
687
+ }): Promise<VoiceResponse>;
688
+ saveChatMessage(message: ChatMessage): void;
689
+ getLocalChatHistory(): Array<ChatMessage & {
690
+ timestamp: Date;
691
+ }>;
692
+ clearChatHistory(): void;
693
+ getChatThreads(): Promise<ChatThread[]>;
694
+ getThreadMessages(threadId: string): Promise<GetThreadMessagesResponse>;
695
+ createThread(): Promise<ChatThread>;
696
+ deleteThread(threadId: string): Promise<void>;
697
+ }
698
+
562
699
  declare class OracleEBSClient {
563
700
  readonly auth: AuthModule;
564
701
  readonly leaves: LeavesModule;
@@ -569,6 +706,7 @@ declare class OracleEBSClient {
569
706
  readonly accrualBalances: AccrualBalancesModule;
570
707
  readonly forms: FormsModule;
571
708
  readonly health: HealthModule;
709
+ readonly ai: AiModule;
572
710
  constructor(config: OracleEBSConfig);
573
711
  setToken(token: string, user?: {
574
712
  userName?: string;
@@ -581,4 +719,4 @@ declare class OracleEBSClient {
581
719
  clearToken(): void;
582
720
  }
583
721
 
584
- export { type APIResponse as A, type GetPayslipDetailsParams as B, type CacheOptions as C, type PayslipDetail as D, type GetPayslipDetailsResponse as E, type PersonalInformation as F, type GetAbsenceTypesParams as G, type EmployeeHierarchyNode as H, type GetEmployeeHierarchyResponse as I, type GetTableColumnsParams as J, type GetTableColumnsResponse as K, type LoginCredentials as L, type DffSegment as M, type Notification as N, OracleEBSClient as O, type ProcessApprovalInput as P, type GetDffSegmentsParams as Q, type RetryOptions as R, type SitSegment as S, type TableColumn as T, type UserContext as U, type GetDffSegmentsResponse as V, type HealthCheckResponse as W, type AccrualBalance as X, type GetAccrualBalancesParams as Y, type GetAccrualBalancesResponse as Z, type OracleEBSConfig as a, type LoginResponse as b, type Responsibility as c, type AbsenceType as d, type GetAbsenceTypesResponse as e, type LeaveHistoryRecord as f, type GetLeaveHistoryResponse as g, type CreateLeaveRequestInput as h, type CreateLeaveRequestResponse as i, type GetSitSegmentsParams as j, type GetSitSegmentsResponse as k, type SaveAndPreviewSitRequestInput as l, type SaveAndPreviewSitRequestResponse as m, type SubmitSitRequestInput as n, type SubmitSitRequestResponse as o, type GetSitHistoryParams as p, type SitHistoryRecord as q, type GetSitHistoryResponse as r, type GetNotificationsResponse as s, type NotificationDetails as t, type GetNotificationDetailsParams as u, type ProcessApprovalResponse as v, type CloseFyiParams as w, type CloseFyiResponse as x, type GetPayslipHeaderParams as y, type PayslipHeader as z };
722
+ export { ActionType as $, type APIResponse as A, type GetPayslipDetailsParams as B, type CacheOptions as C, type PayslipDetail as D, type GetPayslipDetailsResponse as E, type PersonalInformation as F, type GetAbsenceTypesParams as G, type EmployeeHierarchyNode as H, type GetEmployeeHierarchyResponse as I, type GetTableColumnsParams as J, type GetTableColumnsResponse as K, type LoginCredentials as L, type DffSegment as M, type Notification as N, OracleEBSClient as O, type ProcessApprovalInput as P, type GetDffSegmentsParams as Q, type RetryOptions as R, type SitSegment as S, type TableColumn as T, type UserContext as U, type GetDffSegmentsResponse as V, type HealthCheckResponse as W, type AccrualBalance as X, type GetAccrualBalancesParams as Y, type GetAccrualBalancesResponse as Z, MessageRole as _, type OracleEBSConfig as a, UserIntent as a0, type ChatMessage as a1, type CallToAction as a2, type AiResponse as a3, type ChatRequest as a4, type VoiceTranscription as a5, type VoiceResponse as a6, type ChatHistory as a7, type ChatThread as a8, type ThreadMessage as a9, type GetThreadMessagesResponse as aa, type GetThreadsResponse as ab, type CreateThreadResponse as ac, type DeleteThreadResponse as ad, type LoginResponse as b, type Responsibility as c, type AbsenceType as d, type GetAbsenceTypesResponse as e, type LeaveHistoryRecord as f, type GetLeaveHistoryResponse as g, type CreateLeaveRequestInput as h, type CreateLeaveRequestResponse as i, type GetSitSegmentsParams as j, type GetSitSegmentsResponse as k, type SaveAndPreviewSitRequestInput as l, type SaveAndPreviewSitRequestResponse as m, type SubmitSitRequestInput as n, type SubmitSitRequestResponse as o, type GetSitHistoryParams as p, type SitHistoryRecord as q, type GetSitHistoryResponse as r, type GetNotificationsResponse as s, type NotificationDetails as t, type GetNotificationDetailsParams as u, type ProcessApprovalResponse as v, type CloseFyiParams as w, type CloseFyiResponse as x, type GetPayslipHeaderParams as y, type PayslipHeader as z };
@@ -1,6 +1,6 @@
1
1
  import * as _tanstack_react_query from '@tanstack/react-query';
2
2
  import { UseMutationOptions, UseQueryOptions } from '@tanstack/react-query';
3
- import { G as GetAbsenceTypesParams, j as GetSitSegmentsParams, Q as GetDffSegmentsParams, O as OracleEBSClient, b as LoginResponse, L as LoginCredentials, U as UserContext, e as GetAbsenceTypesResponse, g as GetLeaveHistoryResponse, i as CreateLeaveRequestResponse, h as CreateLeaveRequestInput, k as GetSitSegmentsResponse, m as SaveAndPreviewSitRequestResponse, l as SaveAndPreviewSitRequestInput, o as SubmitSitRequestResponse, n as SubmitSitRequestInput, s as GetNotificationsResponse, u as GetNotificationDetailsParams, t as NotificationDetails, v as ProcessApprovalResponse, P as ProcessApprovalInput, y as GetPayslipHeaderParams, z as PayslipHeader, B as GetPayslipDetailsParams, E as GetPayslipDetailsResponse, F as PersonalInformation, I as GetEmployeeHierarchyResponse, Y as GetAccrualBalancesParams, Z as GetAccrualBalancesResponse, J as GetTableColumnsParams, K as GetTableColumnsResponse, V as GetDffSegmentsResponse, W as HealthCheckResponse } from '../OracleEBSClient-C2zQ1MaD.mjs';
3
+ import { G as GetAbsenceTypesParams, j as GetSitSegmentsParams, Q as GetDffSegmentsParams, O as OracleEBSClient, b as LoginResponse, L as LoginCredentials, U as UserContext, e as GetAbsenceTypesResponse, g as GetLeaveHistoryResponse, i as CreateLeaveRequestResponse, h as CreateLeaveRequestInput, k as GetSitSegmentsResponse, m as SaveAndPreviewSitRequestResponse, l as SaveAndPreviewSitRequestInput, o as SubmitSitRequestResponse, n as SubmitSitRequestInput, s as GetNotificationsResponse, u as GetNotificationDetailsParams, t as NotificationDetails, v as ProcessApprovalResponse, P as ProcessApprovalInput, y as GetPayslipHeaderParams, z as PayslipHeader, B as GetPayslipDetailsParams, E as GetPayslipDetailsResponse, F as PersonalInformation, I as GetEmployeeHierarchyResponse, Y as GetAccrualBalancesParams, Z as GetAccrualBalancesResponse, J as GetTableColumnsParams, K as GetTableColumnsResponse, V as GetDffSegmentsResponse, W as HealthCheckResponse } from '../OracleEBSClient-BDnxW4cW.mjs';
4
4
  import 'ky';
5
5
 
6
6
  declare const queryKeys: {
@@ -1,6 +1,6 @@
1
1
  import * as _tanstack_react_query from '@tanstack/react-query';
2
2
  import { UseMutationOptions, UseQueryOptions } from '@tanstack/react-query';
3
- import { G as GetAbsenceTypesParams, j as GetSitSegmentsParams, Q as GetDffSegmentsParams, O as OracleEBSClient, b as LoginResponse, L as LoginCredentials, U as UserContext, e as GetAbsenceTypesResponse, g as GetLeaveHistoryResponse, i as CreateLeaveRequestResponse, h as CreateLeaveRequestInput, k as GetSitSegmentsResponse, m as SaveAndPreviewSitRequestResponse, l as SaveAndPreviewSitRequestInput, o as SubmitSitRequestResponse, n as SubmitSitRequestInput, s as GetNotificationsResponse, u as GetNotificationDetailsParams, t as NotificationDetails, v as ProcessApprovalResponse, P as ProcessApprovalInput, y as GetPayslipHeaderParams, z as PayslipHeader, B as GetPayslipDetailsParams, E as GetPayslipDetailsResponse, F as PersonalInformation, I as GetEmployeeHierarchyResponse, Y as GetAccrualBalancesParams, Z as GetAccrualBalancesResponse, J as GetTableColumnsParams, K as GetTableColumnsResponse, V as GetDffSegmentsResponse, W as HealthCheckResponse } from '../OracleEBSClient-C2zQ1MaD.js';
3
+ import { G as GetAbsenceTypesParams, j as GetSitSegmentsParams, Q as GetDffSegmentsParams, O as OracleEBSClient, b as LoginResponse, L as LoginCredentials, U as UserContext, e as GetAbsenceTypesResponse, g as GetLeaveHistoryResponse, i as CreateLeaveRequestResponse, h as CreateLeaveRequestInput, k as GetSitSegmentsResponse, m as SaveAndPreviewSitRequestResponse, l as SaveAndPreviewSitRequestInput, o as SubmitSitRequestResponse, n as SubmitSitRequestInput, s as GetNotificationsResponse, u as GetNotificationDetailsParams, t as NotificationDetails, v as ProcessApprovalResponse, P as ProcessApprovalInput, y as GetPayslipHeaderParams, z as PayslipHeader, B as GetPayslipDetailsParams, E as GetPayslipDetailsResponse, F as PersonalInformation, I as GetEmployeeHierarchyResponse, Y as GetAccrualBalancesParams, Z as GetAccrualBalancesResponse, J as GetTableColumnsParams, K as GetTableColumnsResponse, V as GetDffSegmentsResponse, W as HealthCheckResponse } from '../OracleEBSClient-BDnxW4cW.js';
4
4
  import 'ky';
5
5
 
6
6
  declare const queryKeys: {
package/dist/index.d.mts CHANGED
@@ -1,5 +1,7 @@
1
- export { A as APIResponse, d as AbsenceType, X as AccrualBalance, C as CacheOptions, w as CloseFyiParams, x as CloseFyiResponse, h as CreateLeaveRequestInput, i as CreateLeaveRequestResponse, M as DffSegment, H as EmployeeHierarchyNode, G as GetAbsenceTypesParams, e as GetAbsenceTypesResponse, Y as GetAccrualBalancesParams, Z as GetAccrualBalancesResponse, Q as GetDffSegmentsParams, V as GetDffSegmentsResponse, I as GetEmployeeHierarchyResponse, g as GetLeaveHistoryResponse, u as GetNotificationDetailsParams, s as GetNotificationsResponse, B as GetPayslipDetailsParams, E as GetPayslipDetailsResponse, y as GetPayslipHeaderParams, p as GetSitHistoryParams, r as GetSitHistoryResponse, j as GetSitSegmentsParams, k as GetSitSegmentsResponse, J as GetTableColumnsParams, K as GetTableColumnsResponse, W as HealthCheckResponse, f as LeaveHistoryRecord, L as LoginCredentials, b as LoginResponse, N as Notification, t as NotificationDetails, O as OracleEBSClient, a as OracleEBSConfig, D as PayslipDetail, z as PayslipHeader, F as PersonalInformation, P as ProcessApprovalInput, v as ProcessApprovalResponse, c as Responsibility, R as RetryOptions, l as SaveAndPreviewSitRequestInput, m as SaveAndPreviewSitRequestResponse, q as SitHistoryRecord, S as SitSegment, n as SubmitSitRequestInput, o as SubmitSitRequestResponse, T as TableColumn, U as UserContext } from './OracleEBSClient-C2zQ1MaD.mjs';
1
+ export { A as APIResponse, d as AbsenceType, X as AccrualBalance, $ as ActionType, a3 as AiResponse, C as CacheOptions, a2 as CallToAction, a7 as ChatHistory, a1 as ChatMessage, a4 as ChatRequest, a8 as ChatThread, w as CloseFyiParams, x as CloseFyiResponse, h as CreateLeaveRequestInput, i as CreateLeaveRequestResponse, ac as CreateThreadResponse, ad as DeleteThreadResponse, M as DffSegment, H as EmployeeHierarchyNode, G as GetAbsenceTypesParams, e as GetAbsenceTypesResponse, Y as GetAccrualBalancesParams, Z as GetAccrualBalancesResponse, Q as GetDffSegmentsParams, V as GetDffSegmentsResponse, I as GetEmployeeHierarchyResponse, g as GetLeaveHistoryResponse, u as GetNotificationDetailsParams, s as GetNotificationsResponse, B as GetPayslipDetailsParams, E as GetPayslipDetailsResponse, y as GetPayslipHeaderParams, p as GetSitHistoryParams, r as GetSitHistoryResponse, j as GetSitSegmentsParams, k as GetSitSegmentsResponse, J as GetTableColumnsParams, K as GetTableColumnsResponse, aa as GetThreadMessagesResponse, ab as GetThreadsResponse, W as HealthCheckResponse, f as LeaveHistoryRecord, L as LoginCredentials, b as LoginResponse, _ as MessageRole, N as Notification, t as NotificationDetails, O as OracleEBSClient, a as OracleEBSConfig, D as PayslipDetail, z as PayslipHeader, F as PersonalInformation, P as ProcessApprovalInput, v as ProcessApprovalResponse, c as Responsibility, R as RetryOptions, l as SaveAndPreviewSitRequestInput, m as SaveAndPreviewSitRequestResponse, q as SitHistoryRecord, S as SitSegment, n as SubmitSitRequestInput, o as SubmitSitRequestResponse, T as TableColumn, a9 as ThreadMessage, U as UserContext, a0 as UserIntent, a6 as VoiceResponse, a5 as VoiceTranscription } from './OracleEBSClient-BDnxW4cW.mjs';
2
+ export { queryKeys, useAccrualBalances, useCreateLeaveRequest, useDffSegments, useEmployeeHierarchy, useHealthCheck, useLeaveHistory, useLeaveTypes, useLogin, useNotificationDetails, useNotifications, usePayslipDetails, usePayslipHeader, usePersonalInfo, useProcessApproval, useSaveAndPreviewSitRequest, useSitSegments, useSubmitSitRequest, useTableColumns, useUserContext } from './hooks/index.mjs';
2
3
  import 'ky';
4
+ import '@tanstack/react-query';
3
5
 
4
6
  declare class APIError extends Error {
5
7
  readonly statusCode: number;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,7 @@
1
- export { A as APIResponse, d as AbsenceType, X as AccrualBalance, C as CacheOptions, w as CloseFyiParams, x as CloseFyiResponse, h as CreateLeaveRequestInput, i as CreateLeaveRequestResponse, M as DffSegment, H as EmployeeHierarchyNode, G as GetAbsenceTypesParams, e as GetAbsenceTypesResponse, Y as GetAccrualBalancesParams, Z as GetAccrualBalancesResponse, Q as GetDffSegmentsParams, V as GetDffSegmentsResponse, I as GetEmployeeHierarchyResponse, g as GetLeaveHistoryResponse, u as GetNotificationDetailsParams, s as GetNotificationsResponse, B as GetPayslipDetailsParams, E as GetPayslipDetailsResponse, y as GetPayslipHeaderParams, p as GetSitHistoryParams, r as GetSitHistoryResponse, j as GetSitSegmentsParams, k as GetSitSegmentsResponse, J as GetTableColumnsParams, K as GetTableColumnsResponse, W as HealthCheckResponse, f as LeaveHistoryRecord, L as LoginCredentials, b as LoginResponse, N as Notification, t as NotificationDetails, O as OracleEBSClient, a as OracleEBSConfig, D as PayslipDetail, z as PayslipHeader, F as PersonalInformation, P as ProcessApprovalInput, v as ProcessApprovalResponse, c as Responsibility, R as RetryOptions, l as SaveAndPreviewSitRequestInput, m as SaveAndPreviewSitRequestResponse, q as SitHistoryRecord, S as SitSegment, n as SubmitSitRequestInput, o as SubmitSitRequestResponse, T as TableColumn, U as UserContext } from './OracleEBSClient-C2zQ1MaD.js';
1
+ export { A as APIResponse, d as AbsenceType, X as AccrualBalance, $ as ActionType, a3 as AiResponse, C as CacheOptions, a2 as CallToAction, a7 as ChatHistory, a1 as ChatMessage, a4 as ChatRequest, a8 as ChatThread, w as CloseFyiParams, x as CloseFyiResponse, h as CreateLeaveRequestInput, i as CreateLeaveRequestResponse, ac as CreateThreadResponse, ad as DeleteThreadResponse, M as DffSegment, H as EmployeeHierarchyNode, G as GetAbsenceTypesParams, e as GetAbsenceTypesResponse, Y as GetAccrualBalancesParams, Z as GetAccrualBalancesResponse, Q as GetDffSegmentsParams, V as GetDffSegmentsResponse, I as GetEmployeeHierarchyResponse, g as GetLeaveHistoryResponse, u as GetNotificationDetailsParams, s as GetNotificationsResponse, B as GetPayslipDetailsParams, E as GetPayslipDetailsResponse, y as GetPayslipHeaderParams, p as GetSitHistoryParams, r as GetSitHistoryResponse, j as GetSitSegmentsParams, k as GetSitSegmentsResponse, J as GetTableColumnsParams, K as GetTableColumnsResponse, aa as GetThreadMessagesResponse, ab as GetThreadsResponse, W as HealthCheckResponse, f as LeaveHistoryRecord, L as LoginCredentials, b as LoginResponse, _ as MessageRole, N as Notification, t as NotificationDetails, O as OracleEBSClient, a as OracleEBSConfig, D as PayslipDetail, z as PayslipHeader, F as PersonalInformation, P as ProcessApprovalInput, v as ProcessApprovalResponse, c as Responsibility, R as RetryOptions, l as SaveAndPreviewSitRequestInput, m as SaveAndPreviewSitRequestResponse, q as SitHistoryRecord, S as SitSegment, n as SubmitSitRequestInput, o as SubmitSitRequestResponse, T as TableColumn, a9 as ThreadMessage, U as UserContext, a0 as UserIntent, a6 as VoiceResponse, a5 as VoiceTranscription } from './OracleEBSClient-BDnxW4cW.js';
2
+ export { queryKeys, useAccrualBalances, useCreateLeaveRequest, useDffSegments, useEmployeeHierarchy, useHealthCheck, useLeaveHistory, useLeaveTypes, useLogin, useNotificationDetails, useNotifications, usePayslipDetails, usePayslipHeader, usePersonalInfo, useProcessApproval, useSaveAndPreviewSitRequest, useSitSegments, useSubmitSitRequest, useTableColumns, useUserContext } from './hooks/index.js';
2
3
  import 'ky';
4
+ import '@tanstack/react-query';
3
5
 
4
6
  declare class APIError extends Error {
5
7
  readonly statusCode: number;