@winwinmbs/portal-api 1.0.0

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.
@@ -0,0 +1,4113 @@
1
+ import type { AxiosInstance } from 'axios';
2
+ import { AxiosRequestConfig } from 'axios';
3
+ import { AxiosResponse } from 'axios';
4
+
5
+ /**
6
+ * Actor types
7
+ */
8
+ declare enum ActorType {
9
+ USER = 'user',
10
+ SYSTEM = 'system',
11
+ SERVICE = 'service',
12
+ API_CLIENT = 'api_client',
13
+ SCHEDULER = 'scheduler',
14
+ WEBHOOK = 'webhook',
15
+ }
16
+ export { ActorType }
17
+ export { ActorType as ActorType_alias_1 }
18
+ export { ActorType as ActorType_alias_2 }
19
+
20
+ declare type ActorTypeType = `${ActorType}`;
21
+ export { ActorTypeType }
22
+ export { ActorTypeType as ActorTypeType_alias_1 }
23
+ export { ActorTypeType as ActorTypeType_alias_2 }
24
+
25
+ /**
26
+ * API Paginated Response Interface
27
+ *
28
+ * @description Interface สำหรับ response ที่มีข้อมูลแบบ paginated พร้อม pagination metadata
29
+ * ใช้สำหรับ API endpoints ที่ส่งข้อมูลเป็น list พร้อม pagination
30
+ *
31
+ * @properties
32
+ * - data: array ของข้อมูลที่ส่งกลับ (required)
33
+ * - pagination: ข้อมูล pagination metadata (required)
34
+ * - success: สถานะความสำเร็จ (inherited)
35
+ * - message: ข้อความตอบกลับ (inherited, optional)
36
+ * - errors: รายการ error messages (inherited, optional)
37
+ * - timestamp: วันเวลาที่ response (inherited)
38
+ * - meta: metadata เพิ่มเติม (inherited, optional)
39
+ *
40
+ * @example
41
+ * ```typescript
42
+ * const usersResponse: ApiPaginatedResponse<IUser> = {
43
+ * success: true,
44
+ * data: [
45
+ * {
46
+ * id: "123",
47
+ * first_name: "สมชาย",
48
+ * last_name: "ใจดี",
49
+ * email: "somchai@example.com"
50
+ * },
51
+ * {
52
+ * id: "456",
53
+ * first_name: "สมหญิง",
54
+ * last_name: "รักดี",
55
+ * email: "somying@example.com"
56
+ * }
57
+ * ],
58
+ * pagination: {
59
+ * page: 1,
60
+ * limit: 20,
61
+ * total: 100,
62
+ * total_pages: 5,
63
+ * has_next: true,
64
+ * has_prev: false
65
+ * },
66
+ * message: "ดึงรายการผู้ใช้สำเร็จ",
67
+ * timestamp: "2024-01-15T10:30:00Z"
68
+ * }
69
+ * ```
70
+ *
71
+ * Usage:
72
+ * import { ApiPaginatedResponse } from '@win-portal/shared/interfaces/helpers/api-paginated-response.interface';
73
+ */
74
+ declare interface ApiPaginatedResponse<T> extends BaseApiResponse {
75
+ data: T[];
76
+ pagination: PaginationMeta;
77
+ }
78
+ export { ApiPaginatedResponse }
79
+ export { ApiPaginatedResponse as ApiPaginatedResponse_alias_1 }
80
+
81
+ /**
82
+ * API Response Interface
83
+ *
84
+ * @description Generic interface สำหรับ wrap ข้อมูลใน API response พร้อม base response structure
85
+ * ใช้สำหรับ response ที่มีข้อมูลเดี่ยวหรือไม่มี pagination
86
+ *
87
+ * @properties
88
+ * - data: ข้อมูลที่ส่งกลับ (optional)
89
+ * - success: สถานะความสำเร็จ (inherited)
90
+ * - message: ข้อความตอบกลับ (inherited, optional)
91
+ * - errors: รายการ error messages (inherited, optional)
92
+ * - timestamp: วันเวลาที่ response (inherited)
93
+ * - meta: metadata เพิ่มเติม (inherited, optional)
94
+ *
95
+ * @example
96
+ * ```typescript
97
+ * const userResponse: ApiResponse<IUser> = {
98
+ * success: true,
99
+ * data: {
100
+ * id: "123",
101
+ * first_name: "สมชาย",
102
+ * last_name: "ใจดี",
103
+ * email: "somchai@example.com"
104
+ * },
105
+ * message: "ดึงข้อมูลผู้ใช้สำเร็จ",
106
+ * timestamp: "2024-01-15T10:30:00Z"
107
+ * }
108
+ *
109
+ * const errorResponse: ApiResponse<null> = {
110
+ * success: false,
111
+ * data: null,
112
+ * errors: ["ไม่พบข้อมูลผู้ใช้"],
113
+ * timestamp: "2024-01-15T10:30:00Z"
114
+ * }
115
+ * ```
116
+ *
117
+ * Usage:
118
+ * import { ApiResponse } from '@win-portal/shared/interfaces/helpers/api-response.interface';
119
+ */
120
+ declare interface ApiResponse<T> extends BaseApiResponse {
121
+ data?: T;
122
+ }
123
+ export { ApiResponse }
124
+ export { ApiResponse as ApiResponse_alias_1 }
125
+
126
+ /**
127
+ * Assignment Response - ผลลัพธ์จากการมอบหมาย/ยกเลิกการมอบหมาย
128
+ *
129
+ * @note Diverges from @win-portal/shared `AssignmentResponseDto`. This SDK
130
+ * shape tracks `assigned / unassigned / total` counts, while the server DTO
131
+ * tracks `assigned_count / failed_count / total_count` plus per-item detail.
132
+ * Kept local to reflect the simplified summary the SDK exposes to callers.
133
+ */
134
+ declare interface AssignmentResponse {
135
+ assigned?: number;
136
+ unassigned?: number;
137
+ total?: number;
138
+ }
139
+ export { AssignmentResponse }
140
+ export { AssignmentResponse as AssignmentResponse_alias_1 }
141
+ export { AssignmentResponse as AssignmentResponse_alias_2 }
142
+
143
+ /**
144
+ * Assign Positions Request - ข้อมูลสำหรับการมอบหมายตำแหน่งให้ผู้ใช้
145
+ *
146
+ * Structurally identical to `@win-portal/shared` `AssignPositionsRequestDto`.
147
+ * Kept local so api-extractor can inline the shape into the published dts.
148
+ *
149
+ * @example
150
+ * ```json
151
+ * {
152
+ * "positions": [
153
+ * { "position_id": "pos-123", "is_primary": true },
154
+ * { "position_id": "pos-456", "is_primary": false }
155
+ * ],
156
+ * "mode": "replace"
157
+ * }
158
+ * ```
159
+ */
160
+ declare interface AssignPositionsRequest {
161
+ positions: UserPositionAssignment[];
162
+ mode?: 'add' | 'replace';
163
+ }
164
+ export { AssignPositionsRequest }
165
+ export { AssignPositionsRequest as AssignPositionsRequest_alias_1 }
166
+ export { AssignPositionsRequest as AssignPositionsRequest_alias_2 }
167
+
168
+ /**
169
+ * Base API Response Interface
170
+ *
171
+ * @description Interface พื้นฐานสำหรับ response ของ API endpoints ทั้งหมด
172
+ * รวมถึงสถานะความสำเร็จ ข้อความ และ metadata
173
+ *
174
+ * @properties
175
+ * - success: สถานะความสำเร็จ (required)
176
+ * - message: ข้อความตอบกลับ (optional)
177
+ * - errors: รายการ error messages (optional)
178
+ * - timestamp: วันเวลาที่ response (required)
179
+ * - meta: metadata เพิ่มเติม (optional)
180
+ *
181
+ * @example
182
+ * ```typescript
183
+ * const baseResponse: BaseApiResponse = {
184
+ * success: true,
185
+ * message: "บันทึกข้อมูลเรียบร้อย",
186
+ * timestamp: "2024-01-15T10:30:00Z",
187
+ * meta: {
188
+ * version: "1.0",
189
+ * request_id: "req-123"
190
+ * }
191
+ * }
192
+ * ```
193
+ *
194
+ * Usage:
195
+ * import { BaseApiResponse } from '@win-portal/shared/interfaces/helpers/base-api-response.interface';
196
+ */
197
+ declare interface BaseApiResponse {
198
+ success: boolean;
199
+ message?: string;
200
+ errors?: string[];
201
+ timestamp: string;
202
+ meta?: {
203
+ [key: string]: any;
204
+ };
205
+ }
206
+
207
+ /**
208
+ * Bulk Create Organization Request - สร้างหลายรายการในครั้งเดียว
209
+ */
210
+ declare interface BulkCreateOrganizationRequest {
211
+ organizations: CreateOrganizationRequest[];
212
+ /** ข้าม rebuild-all หลังสร้าง (default: false) */
213
+ skip_rebuild?: boolean;
214
+ }
215
+ export { BulkCreateOrganizationRequest }
216
+ export { BulkCreateOrganizationRequest as BulkCreateOrganizationRequest_alias_1 }
217
+ export { BulkCreateOrganizationRequest as BulkCreateOrganizationRequest_alias_2 }
218
+
219
+ /**
220
+ * Bulk Create Organization Response
221
+ */
222
+ declare interface BulkCreateOrganizationResponse {
223
+ created: number;
224
+ errors: {
225
+ index: number;
226
+ message: string;
227
+ }[];
228
+ execution_time_ms: number;
229
+ }
230
+ export { BulkCreateOrganizationResponse }
231
+ export { BulkCreateOrganizationResponse as BulkCreateOrganizationResponse_alias_1 }
232
+ export { BulkCreateOrganizationResponse as BulkCreateOrganizationResponse_alias_2 }
233
+
234
+ /**
235
+ * Bulk Create Permission Category Item - รองรับ id เพื่อให้ child อ้างอิง parent_id ใน batch เดียวกัน
236
+ */
237
+ declare interface BulkCreatePermissionCategoryItem extends CreatePermissionCategoryRequest {
238
+ /** Optional: หากระบุจะใช้ id นี้ (สำหรับให้ child อ้างอิง parent_id ใน batch เดียวกัน) */
239
+ id?: string;
240
+ }
241
+ export { BulkCreatePermissionCategoryItem }
242
+ export { BulkCreatePermissionCategoryItem as BulkCreatePermissionCategoryItem_alias_1 }
243
+ export { BulkCreatePermissionCategoryItem as BulkCreatePermissionCategoryItem_alias_2 }
244
+
245
+ /**
246
+ * Bulk Create Permission Category Request
247
+ */
248
+ declare interface BulkCreatePermissionCategoryRequest {
249
+ permission_categories: BulkCreatePermissionCategoryItem[];
250
+ }
251
+ export { BulkCreatePermissionCategoryRequest }
252
+ export { BulkCreatePermissionCategoryRequest as BulkCreatePermissionCategoryRequest_alias_1 }
253
+ export { BulkCreatePermissionCategoryRequest as BulkCreatePermissionCategoryRequest_alias_2 }
254
+
255
+ /**
256
+ * Bulk Create Permission Request
257
+ */
258
+ declare interface BulkCreatePermissionRequest {
259
+ permissions: CreatePermissionRequest[];
260
+ }
261
+ export { BulkCreatePermissionRequest }
262
+ export { BulkCreatePermissionRequest as BulkCreatePermissionRequest_alias_1 }
263
+ export { BulkCreatePermissionRequest as BulkCreatePermissionRequest_alias_2 }
264
+
265
+ /**
266
+ * Bulk Create Response - ใช้ร่วมกับ permission และ permission-category
267
+ */
268
+ declare interface BulkCreateResponse {
269
+ created: number;
270
+ errors: {
271
+ index: number;
272
+ message: string;
273
+ }[];
274
+ execution_time_ms: number;
275
+ }
276
+ export { BulkCreateResponse }
277
+ export { BulkCreateResponse as BulkCreateResponse_alias_1 }
278
+ export { BulkCreateResponse as BulkCreateResponse_alias_2 }
279
+
280
+ /**
281
+ * Bulk Operation Response - ผลลัพธ์จาก bulk operations
282
+ */
283
+ declare interface BulkOperationResponse {
284
+ success_count: number;
285
+ fail_count: number;
286
+ }
287
+ export { BulkOperationResponse }
288
+ export { BulkOperationResponse as BulkOperationResponse_alias_1 }
289
+ export { BulkOperationResponse as BulkOperationResponse_alias_2 }
290
+
291
+ /**
292
+ * Clear All Data Response - ผลลัพธ์จากการลบข้อมูลองค์กรทั้งหมด
293
+ *
294
+ * @description ใช้กับ organization.clearAll() - ลบ user_position_assignment, organization_closure,
295
+ * organization และ nullify references ใน workflow/document tables
296
+ */
297
+ declare interface ClearAllDataResponse {
298
+ user_position_assignments_deleted: number;
299
+ organization_closure_deleted: number;
300
+ organizations_deleted: number;
301
+ workflow_references_nullified: number;
302
+ document_references_cleared: number;
303
+ }
304
+ export { ClearAllDataResponse }
305
+ export { ClearAllDataResponse as ClearAllDataResponse_alias_1 }
306
+ export { ClearAllDataResponse as ClearAllDataResponse_alias_2 }
307
+
308
+ /**
309
+ * Create Event Log Request DTO
310
+ *
311
+ * Complete interface for creating event logs
312
+ */
313
+ declare interface CreateEventLogRequestDto {
314
+ source: string;
315
+ event_type: string;
316
+ subject?: string;
317
+ event_time?: Date | string;
318
+ application_id?: string | null;
319
+ application_code?: string;
320
+ severity?: EventSeverity;
321
+ outcome?: EventOutcome;
322
+ category?: EventCategory;
323
+ risk_level?: EventRiskLevel;
324
+ actor?: IEventLogActor;
325
+ target?: IEventLogTarget;
326
+ action?: string;
327
+ message?: string;
328
+ before_state?: Record<string, any>;
329
+ after_state?: Record<string, any>;
330
+ changed_fields?: Record<string, any>;
331
+ metadata?: Record<string, any>;
332
+ tags?: string[];
333
+ error?: IEventLogError;
334
+ trace_id?: string;
335
+ span_id?: string;
336
+ parent_span_id?: string;
337
+ trace_flags?: string;
338
+ correlation_id?: string;
339
+ request_id?: string;
340
+ business_reason?: string;
341
+ application_version?: string;
342
+ service_version?: string;
343
+ performance?: {
344
+ duration_ms?: number;
345
+ resource_usage?: Record<string, any>;
346
+ };
347
+ requires_approval?: boolean;
348
+ approval?: {
349
+ required: boolean;
350
+ approved_by?: string;
351
+ approved_at?: Date;
352
+ rejected_by?: string;
353
+ rejected_at?: Date;
354
+ reason?: string;
355
+ };
356
+ review?: {
357
+ required: boolean;
358
+ reviewed_by?: string;
359
+ reviewed_at?: Date;
360
+ status?: 'pending' | 'approved' | 'rejected';
361
+ notes?: string;
362
+ };
363
+ retention_period?: string;
364
+ expires_at?: Date;
365
+ }
366
+ export { CreateEventLogRequestDto }
367
+ export { CreateEventLogRequestDto as CreateEventLogRequestDto_alias_1 }
368
+ export { CreateEventLogRequestDto as CreateEventLogRequestDto_alias_2 }
369
+
370
+ /**
371
+ * Create Organization Request
372
+ */
373
+ declare interface CreateOrganizationRequest {
374
+ id?: string;
375
+ name: string;
376
+ code: string;
377
+ type: OrganizationType | string;
378
+ parent_id?: string;
379
+ description?: string;
380
+ logo_file_id?: string;
381
+ report_to_position_id?: string;
382
+ }
383
+ export { CreateOrganizationRequest }
384
+ export { CreateOrganizationRequest as CreateOrganizationRequest_alias_1 }
385
+ export { CreateOrganizationRequest as CreateOrganizationRequest_alias_2 }
386
+
387
+ /**
388
+ * Create Permission Category Request
389
+ *
390
+ * @note application_id - Optional เมื่อเรียกจาก app context (API key หรือ RequestContext)
391
+ * API จะ inject application_id อัตโนมัติจาก API key หรือ RequestContextService
392
+ */
393
+ declare interface CreatePermissionCategoryRequest {
394
+ /** Optional: หากระบุจะใช้ id นี้แทนการ generate ใหม่ (สำหรับ import/migration หรือให้ child อ้างอิง parent_id) */
395
+ id?: string;
396
+ /** Optional: API จะ inject จาก API key หรือ RequestContextService เมื่อมี context */
397
+ application_id?: string;
398
+ key: string;
399
+ name: string;
400
+ description?: string;
401
+ resource?: string;
402
+ parent_id?: string;
403
+ permissions?: Omit<CreatePermissionRequest, 'category_id'>[];
404
+ }
405
+ export { CreatePermissionCategoryRequest }
406
+ export { CreatePermissionCategoryRequest as CreatePermissionCategoryRequest_alias_1 }
407
+ export { CreatePermissionCategoryRequest as CreatePermissionCategoryRequest_alias_2 }
408
+
409
+ /**
410
+ * Create Permission Request
411
+ */
412
+ declare interface CreatePermissionRequest {
413
+ /** Optional: หากระบุจะใช้ id นี้แทนการ generate ใหม่ (สำหรับ import/migration) */
414
+ id?: string;
415
+ category_id: string;
416
+ name: string;
417
+ key: string;
418
+ description?: string;
419
+ application_id?: string;
420
+ }
421
+ export { CreatePermissionRequest }
422
+ export { CreatePermissionRequest as CreatePermissionRequest_alias_1 }
423
+ export { CreatePermissionRequest as CreatePermissionRequest_alias_2 }
424
+
425
+ /**
426
+ * Create Role Request - ข้อมูลสำหรับสร้างบทบาทใหม่
427
+ */
428
+ declare interface CreateRoleRequest {
429
+ /** Optional: หากระบุจะใช้ id นี้แทนการ generate ใหม่ (สำหรับ import/migration) */
430
+ id?: string;
431
+ name: string;
432
+ code: string;
433
+ description?: string;
434
+ }
435
+ export { CreateRoleRequest }
436
+ export { CreateRoleRequest as CreateRoleRequest_alias_1 }
437
+ export { CreateRoleRequest as CreateRoleRequest_alias_2 }
438
+
439
+ /**
440
+ * Create Todo Request
441
+ *
442
+ * @description Request data for creating a new todo
443
+ *
444
+ * @properties
445
+ * - title: หัวข้องาน (required) ชื่อหรือหัวข้อของงานที่ต้องทำ
446
+ * - description: รายละเอียดงาน (optional) คำอธิบายเพิ่มเติมของงาน
447
+ * - due_date: วันครบกำหนด (optional) วันที่ต้องเสร็จงาน
448
+ * - priority: ระดับความสำคัญ (required) เช่น low, normal, high
449
+ * - category: หมวดหมู่ (optional) เช่น "work", "personal", "shopping"
450
+ * - labels: ป้ายกำกับ (optional) tags สำหรับการค้นหาและจัดกลุ่ม
451
+ * - link_url: ลิงก์อ้างอิง (optional) URL ที่เกี่ยวข้องกับงาน
452
+ * - metadata: ข้อมูลเพิ่มเติม (optional) object สำหรับเก็บข้อมูลที่เกี่ยวข้อง
453
+ * - is_send_notification: ส่งการแจ้งเตือน (optional) default = true
454
+ * - user_id: รหัสผู้ใช้ (required) user ID ที่เป็นเจ้าของ todo
455
+ * - parent_id: รหัส parent todo (optional) สำหรับสร้าง sub-task
456
+ * - order: ลำดับ sub-task (optional) สำหรับเรียง sub-tasks
457
+ * - assigned_to_id: ผู้รับผิดชอบหลัก (optional) user ID ของผู้ที่ต้องทำงาน
458
+ *
459
+ * @example
460
+ * ```typescript
461
+ * const todo = await authClient.todo.create({
462
+ * title: "ซื้อของใช้ในบ้าน",
463
+ * description: "ซื้อน้ำยาล้างจาน, กระดาษทิชชู่, แชมพู",
464
+ * due_date: new Date("2024-01-20T17:00:00Z"),
465
+ * priority: TodoPriority.NORMAL,
466
+ * category: "shopping",
467
+ * labels: ["บ้าน", "จำเป็น"],
468
+ * link_url: "https://www.bigc.co.th/shopping-list",
469
+ * user_id: "user123e4567-e89b-12d3-a456-426614174000",
470
+ * is_send_notification: true
471
+ * });
472
+ * ```
473
+ */
474
+ declare interface CreateTodoRequest {
475
+ title: string;
476
+ priority: TodoPriority;
477
+ user_id: string;
478
+ description?: string;
479
+ due_date?: Date | string;
480
+ category?: string;
481
+ labels?: string[];
482
+ link_url?: string;
483
+ metadata?: Record<string, any>;
484
+ is_send_notification?: boolean;
485
+ parent_id?: string;
486
+ order?: number;
487
+ assigned_to_id?: string;
488
+ }
489
+ export { CreateTodoRequest }
490
+ export { CreateTodoRequest as CreateTodoRequest_alias_1 }
491
+ export { CreateTodoRequest as CreateTodoRequest_alias_2 }
492
+
493
+ /**
494
+ * Create User Request - ข้อมูลสำหรับสร้างผู้ใช้ใหม่
495
+ * Matches CreateUserRequestDto from @win-portal/shared
496
+ *
497
+ * @description ถ้าไม่ระบุ password ระบบจะ auto generate และส่ง reset password link ไปทางอีเมล
498
+ * ถ้าระบุ password ระบบจะใช้ password ที่ส่งมาและส่ง welcome email พร้อม login link
499
+ */
500
+ declare interface CreateUserRequest {
501
+ email: string;
502
+ username?: string;
503
+ first_name: string;
504
+ last_name: string;
505
+ first_name_en?: string;
506
+ last_name_en?: string;
507
+ code?: string;
508
+ phone_number?: string;
509
+ avatar_file_id?: string;
510
+ signature_file_id?: string;
511
+ password?: string;
512
+ ignore_password_policies?: boolean;
513
+ role_ids?: string[];
514
+ metadata?: Record<string, any>;
515
+ id?: string;
516
+ }
517
+ export { CreateUserRequest }
518
+ export { CreateUserRequest as CreateUserRequest_alias_1 }
519
+ export { CreateUserRequest as CreateUserRequest_alias_2 }
520
+
521
+ /**
522
+ * Create Workflow Instance Request
523
+ */
524
+ declare interface CreateWorkflowInstanceRequest {
525
+ workflow_definition_id: string;
526
+ document_id: string;
527
+ document_type: string;
528
+ document_title: string;
529
+ document_url?: string;
530
+ priority: 'low' | 'normal' | 'high' | 'urgent';
531
+ position_id: string;
532
+ form_data: Record<string, any>;
533
+ context_variables?: Record<string, any>;
534
+ workflow_config?: Record<string, any>;
535
+ auto_start?: boolean;
536
+ due_date_override?: Date;
537
+ user_id: string;
538
+ }
539
+ export { CreateWorkflowInstanceRequest }
540
+ export { CreateWorkflowInstanceRequest as CreateWorkflowInstanceRequest_alias_1 }
541
+ export { CreateWorkflowInstanceRequest as CreateWorkflowInstanceRequest_alias_2 }
542
+
543
+ /**
544
+ * Email API
545
+ *
546
+ * @example
547
+ * ```typescript
548
+ * // Template Mode
549
+ * const result = await authClient.email.sendEmail({
550
+ * template_code: 'welcome_email',
551
+ * template_data: {
552
+ * userName: 'สมชาย ใจดี',
553
+ * activationLink: 'https://app.com/activate?token=xxx'
554
+ * },
555
+ * recipient_email: 'user@example.com',
556
+ * recipient_name: 'สมชาย ใจดี',
557
+ * language: 'th',
558
+ * cc: ['manager@example.com'],
559
+ * attachments: [
560
+ * {
561
+ * filename: 'welcome.pdf',
562
+ * href: 'https://api.example.com/files/123e4567-e89b-12d3-a456-426614174000/content' // URL จาก File API
563
+ * }
564
+ * ]
565
+ * });
566
+ *
567
+ * // Raw HTML Mode
568
+ * const result = await authClient.email.sendEmail({
569
+ * html_body: '<h1>ยินดีต้อนรับ</h1><p>ขอบคุณที่สมัครสมาชิก</p>',
570
+ * subject: 'ยินดีต้อนรับสู่ระบบ',
571
+ * recipient_email: 'user@example.com',
572
+ * recipient_name: 'สมชาย ใจดี',
573
+ * text_body: 'ยินดีต้อนรับ ขอบคุณที่สมัครสมาชิก',
574
+ * cc: ['manager@example.com'],
575
+ * bcc: ['archive@example.com']
576
+ * });
577
+ * ```
578
+ */
579
+ declare class EmailAPI {
580
+ private readonly axios;
581
+ constructor(axios: AxiosInstance);
582
+ /**
583
+ * Send email (auto-detect Template Mode or Raw HTML Mode)
584
+ *
585
+ * @param request - SendEmailRequest
586
+ * @returns SendEmailResponse
587
+ *
588
+ * @example
589
+ * ```typescript
590
+ * // Template Mode
591
+ * const result = await authClient.email.sendEmail({
592
+ * template_code: 'welcome_email',
593
+ * template_data: { userName: 'John' },
594
+ * recipient_email: 'user@example.com'
595
+ * });
596
+ *
597
+ * // Raw HTML Mode
598
+ * const result = await authClient.email.sendEmail({
599
+ * html_body: '<h1>Hello</h1>',
600
+ * subject: 'Welcome',
601
+ * recipient_email: 'user@example.com'
602
+ * });
603
+ * ```
604
+ */
605
+ sendEmail(request: SendEmailRequest): Promise<SendEmailResponse>;
606
+ /**
607
+ * Send email with template (Template Mode - convenience method)
608
+ *
609
+ * @param templateCode - Template code from database
610
+ * @param templateData - Template data for rendering
611
+ * @param recipient - Email address or user ID
612
+ * @param options - Additional options (cc, bcc, attachments, etc.)
613
+ * @returns SendEmailResponse
614
+ *
615
+ * @example
616
+ * ```typescript
617
+ * const result = await authClient.email.sendEmailWithTemplate(
618
+ * 'welcome_email',
619
+ * {
620
+ * userName: 'สมชาย ใจดี',
621
+ * activationLink: 'https://app.com/activate?token=xxx'
622
+ * },
623
+ * 'user@example.com',
624
+ * {
625
+ * recipient_name: 'สมชาย ใจดี',
626
+ * language: 'th',
627
+ * cc: ['manager@example.com'],
628
+ * attachments: [
629
+ * {
630
+ * filename: 'welcome.pdf',
631
+ * href: 'https://storage.azure.com/container/welcome.pdf' // URL จาก cloud storage
632
+ * }
633
+ * ]
634
+ * }
635
+ * );
636
+ * ```
637
+ */
638
+ sendEmailWithTemplate(templateCode: string, templateData: Record<string, any>, recipient: string, options?: {
639
+ recipient_name?: string;
640
+ recipient_id?: string;
641
+ language?: 'th' | 'en';
642
+ subject?: string;
643
+ cc?: string | string[];
644
+ bcc?: string | string[];
645
+ attachments?: Array<{
646
+ filename: string;
647
+ href: string;
648
+ content_type?: string;
649
+ }>;
650
+ priority?: 'low' | 'normal' | 'high' | 'urgent';
651
+ scheduled_at?: Date | string;
652
+ source?: string;
653
+ related_entity_id?: string;
654
+ related_entity_type?: string;
655
+ }): Promise<SendEmailResponse>;
656
+ /**
657
+ * Send email with raw HTML (Raw HTML Mode - convenience method)
658
+ *
659
+ * @param htmlBody - HTML content
660
+ * @param subject - Email subject
661
+ * @param recipient - Email address or user ID
662
+ * @param options - Additional options (text_body, cc, bcc, attachments, etc.)
663
+ * @returns SendEmailResponse
664
+ *
665
+ * @example
666
+ * ```typescript
667
+ * const result = await authClient.email.sendRawEmail(
668
+ * '<h1>ยินดีต้อนรับ</h1><p>ขอบคุณที่สมัครสมาชิก</p>',
669
+ * 'ยินดีต้อนรับสู่ระบบ',
670
+ * 'user@example.com',
671
+ * {
672
+ * recipient_name: 'สมชาย ใจดี',
673
+ * text_body: 'ยินดีต้อนรับ ขอบคุณที่สมัครสมาชิก',
674
+ * cc: ['manager@example.com'],
675
+ * bcc: ['archive@example.com'],
676
+ * attachments: [
677
+ * {
678
+ * filename: 'document.pdf',
679
+ * href: 'https://api.example.com/files/123e4567-e89b-12d3-a456-426614174000/content' // URL จาก File API
680
+ * }
681
+ * ]
682
+ * }
683
+ * );
684
+ * ```
685
+ */
686
+ sendRawEmail(htmlBody: string, subject: string, recipient: string, options?: {
687
+ recipient_name?: string;
688
+ recipient_id?: string;
689
+ text_body?: string;
690
+ cc?: string | string[];
691
+ bcc?: string | string[];
692
+ attachments?: Array<{
693
+ filename: string;
694
+ href: string;
695
+ content_type?: string;
696
+ }>;
697
+ priority?: 'low' | 'normal' | 'high' | 'urgent';
698
+ scheduled_at?: Date | string;
699
+ source?: string;
700
+ related_entity_id?: string;
701
+ related_entity_type?: string;
702
+ }): Promise<SendEmailResponse>;
703
+ }
704
+ export { EmailAPI }
705
+ export { EmailAPI as EmailAPI_alias_1 }
706
+ export { EmailAPI as EmailAPI_alias_2 }
707
+
708
+ /**
709
+ * Event categories (ISO 27001 Compliant - 8 Core Categories)
710
+ */
711
+ declare enum EventCategory {
712
+ // === 8 Core Categories ===
713
+ AUTHENTICATION = 'authentication', // 1. Login, logout, password, MFA, account management
714
+ AUTHORIZATION = 'authorization', // 2. Permission checks, role assignments, access control
715
+ DATA_ACCESS = 'data_access', // 3. Data viewing, export, search, sensitive data access
716
+ SECURITY = 'security', // 4. Attack attempts, suspicious activities, threat detection
717
+ BUSINESS = 'business', // 5. CRUD operations, workflow, business operations (รวม DATA_CHANGE)
718
+ TECHNICAL = 'technical', // 6. System lifecycle, performance, API operations, errors
719
+ COMPLIANCE = 'compliance', // 7. Audit activities, GDPR, legal hold, policy compliance
720
+ ISO27001_AUDIT = 'iso27001_audit', // 8. Control monitoring, risk management, ISMS
721
+ }
722
+ export { EventCategory }
723
+ export { EventCategory as EventCategory_alias_1 }
724
+ export { EventCategory as EventCategory_alias_2 }
725
+
726
+ declare type EventCategoryType = `${EventCategory}`;
727
+ export { EventCategoryType }
728
+ export { EventCategoryType as EventCategoryType_alias_1 }
729
+ export { EventCategoryType as EventCategoryType_alias_2 }
730
+
731
+ /**
732
+ * Event Log API Client
733
+ *
734
+ * Centralized event logging client for microservices
735
+ * Sends all event logs to main API for centralized storage
736
+ */
737
+ declare class EventLogApi {
738
+ private readonly axios;
739
+ constructor(axios: AxiosInstance);
740
+ /**
741
+ * Log event to centralized event log system
742
+ */
743
+ logEvent(eventData: CreateEventLogRequestDto): Promise<EventLogResponseDto>;
744
+ /**
745
+ * Batch log multiple events (for performance)
746
+ */
747
+ logEvents(events: CreateEventLogRequestDto[]): Promise<{
748
+ success: number;
749
+ failed: number;
750
+ }>;
751
+ }
752
+ export { EventLogApi }
753
+ export { EventLogApi as EventLogApi_alias_1 }
754
+ export { EventLogApi as EventLogApi_alias_2 }
755
+
756
+ /**
757
+ * Event Log Response DTO
758
+ * Matches EventLogResponseDto from @win-portal/shared
759
+ */
760
+ declare interface EventLogResponseDto {
761
+ id: string;
762
+ created_at: string;
763
+ updated_at: string;
764
+ status: string;
765
+ source: string;
766
+ event_type: string;
767
+ subject?: string;
768
+ event_time: string;
769
+ severity: string;
770
+ outcome: string;
771
+ category?: string;
772
+ risk_level?: string;
773
+ application_id?: string | null;
774
+ application_code?: string;
775
+ actor: {
776
+ type: string;
777
+ id?: string;
778
+ name?: string;
779
+ session_id?: string;
780
+ ip_address?: string;
781
+ user_agent?: string;
782
+ };
783
+ target?: {
784
+ type: string;
785
+ id?: string;
786
+ name?: string;
787
+ };
788
+ action: string;
789
+ message?: string;
790
+ before_state?: Record<string, any>;
791
+ after_state?: Record<string, any>;
792
+ changed_fields?: Record<string, any>;
793
+ metadata?: Record<string, any>;
794
+ tags?: string[];
795
+ error?: {
796
+ code?: string;
797
+ message?: string;
798
+ details?: any;
799
+ };
800
+ trace_id?: string;
801
+ span_id?: string;
802
+ parent_span_id?: string;
803
+ trace_flags?: string;
804
+ correlation_id?: string;
805
+ request_id?: string;
806
+ business_reason?: string;
807
+ application_version?: string;
808
+ service_version?: string;
809
+ performance?: {
810
+ duration_ms?: number;
811
+ resource_usage?: Record<string, any>;
812
+ };
813
+ requires_approval?: boolean;
814
+ approval?: {
815
+ required: boolean;
816
+ approved_by?: string;
817
+ approved_at?: Date | string;
818
+ rejected_by?: string;
819
+ rejected_at?: Date | string;
820
+ reason?: string;
821
+ };
822
+ review?: {
823
+ required: boolean;
824
+ reviewed_by?: string;
825
+ reviewed_at?: Date | string;
826
+ status?: 'pending' | 'approved' | 'rejected';
827
+ notes?: string;
828
+ };
829
+ retention_period?: string;
830
+ expires_at?: Date | string;
831
+ event_age_hours?: number;
832
+ is_recent?: boolean;
833
+ risk_score?: number;
834
+ related_events_count?: number;
835
+ }
836
+ export { EventLogResponseDto }
837
+ export { EventLogResponseDto as EventLogResponseDto_alias_1 }
838
+ export { EventLogResponseDto as EventLogResponseDto_alias_2 }
839
+
840
+ /**
841
+ * Event outcome
842
+ */
843
+ declare enum EventOutcome {
844
+ SUCCESS = 'success',
845
+ FAILURE = 'failure',
846
+ PARTIAL = 'partial',
847
+ UNKNOWN = 'unknown',
848
+ }
849
+ export { EventOutcome }
850
+ export { EventOutcome as EventOutcome_alias_1 }
851
+ export { EventOutcome as EventOutcome_alias_2 }
852
+
853
+ declare type EventOutcomeType = `${EventOutcome}`;
854
+ export { EventOutcomeType }
855
+ export { EventOutcomeType as EventOutcomeType_alias_1 }
856
+ export { EventOutcomeType as EventOutcomeType_alias_2 }
857
+
858
+ /**
859
+ * Risk levels
860
+ */
861
+ declare enum EventRiskLevel {
862
+ NONE = 'none',
863
+ LOW = 'low',
864
+ MEDIUM = 'medium',
865
+ HIGH = 'high',
866
+ CRITICAL = 'critical',
867
+ }
868
+ export { EventRiskLevel }
869
+ export { EventRiskLevel as EventRiskLevel_alias_1 }
870
+ export { EventRiskLevel as EventRiskLevel_alias_2 }
871
+
872
+ declare type EventRiskLevelType = `${EventRiskLevel}`;
873
+ export { EventRiskLevelType }
874
+ export { EventRiskLevelType as EventRiskLevelType_alias_1 }
875
+ export { EventRiskLevelType as EventRiskLevelType_alias_2 }
876
+
877
+ /**
878
+ * Event severity levels
879
+ */
880
+ declare enum EventSeverity {
881
+ DEBUG = 'debug',
882
+ INFO = 'info',
883
+ WARNING = 'warning',
884
+ ERROR = 'error',
885
+ CRITICAL = 'critical',
886
+ }
887
+ export { EventSeverity }
888
+ export { EventSeverity as EventSeverity_alias_1 }
889
+ export { EventSeverity as EventSeverity_alias_2 }
890
+
891
+ declare type EventSeverityType = `${EventSeverity}`;
892
+ export { EventSeverityType }
893
+ export { EventSeverityType as EventSeverityType_alias_1 }
894
+ export { EventSeverityType as EventSeverityType_alias_2 }
895
+
896
+ /**
897
+ * File Types - SDK Friendly
898
+ *
899
+ * Clean, client-focused type names without DTO suffixes
900
+ */
901
+ /**
902
+ * File Information
903
+ * Complete file metadata and URLs
904
+ * Matches FileResponseDto from @win-portal/shared
905
+ */
906
+ declare interface File_2 {
907
+ id: string;
908
+ created_at: string;
909
+ updated_at: string;
910
+ status: string;
911
+ original_name: string;
912
+ file_name: string;
913
+ url: string;
914
+ mime_type: string;
915
+ size: number;
916
+ folder?: string;
917
+ storage_provider: string;
918
+ entity_type: string;
919
+ entity_id: string;
920
+ entity_field?: string;
921
+ file_category: string;
922
+ description?: string;
923
+ is_public: boolean;
924
+ checksum?: string;
925
+ metadata?: Record<string, any>;
926
+ uploaded_by?: string;
927
+ uploaded_by_name?: string;
928
+ download_count?: number;
929
+ last_accessed_at?: string;
930
+ file_size_formatted?: string;
931
+ is_image?: boolean;
932
+ is_document?: boolean;
933
+ is_video?: boolean;
934
+ is_audio?: boolean;
935
+ thumbnail_url?: string;
936
+ preview_url?: string;
937
+ download_url?: string;
938
+ }
939
+ export { File_2 as File }
940
+ export { File_2 as File_alias_1 }
941
+ export { File_2 as File_alias_2 }
942
+
943
+ /**
944
+ * Files API
945
+ * Methods for file management operations
946
+ * Based on: apps/api/src/modules/features/files/controllers/files.controller.ts
947
+ */
948
+ declare class FilesAPI {
949
+ private readonly axios;
950
+ constructor(axios: AxiosInstance);
951
+ /**
952
+ * POST /files - อัปโหลดไฟล์ใหม่
953
+ * Supports both authenticated and anonymous uploads
954
+ */
955
+ upload(formData: FormData): Promise<File_2>;
956
+ /**
957
+ * GET /files/:id - ดูข้อมูลไฟล์
958
+ * Public access (supports both authenticated and anonymous)
959
+ */
960
+ getById(id: string): Promise<File_2>;
961
+ /**
962
+ * GET /files/:id/content - ดึง file content (รูปภาพ, เอกสาร)
963
+ * Returns the actual file content or redirects to cloud storage URL
964
+ * Public access based on file.is_public flag
965
+ */
966
+ getContentUrl(id: string): string;
967
+ /**
968
+ * PUT /files/:id - อัปเดตข้อมูลไฟล์
969
+ * Requires authentication
970
+ */
971
+ update(id: string, updateData: FileUpdateData): Promise<File_2>;
972
+ /**
973
+ * DELETE /files/:id - ลบไฟล์
974
+ * Requires authentication
975
+ */
976
+ delete(id: string): Promise<{
977
+ message: string;
978
+ }>;
979
+ /**
980
+ * POST /files/search - ค้นหาไฟล์แบบ advanced
981
+ * Public access (supports both authenticated and anonymous)
982
+ */
983
+ search(searchParams?: FileSearchParams): Promise<{
984
+ data: File_2[];
985
+ total: number;
986
+ page: number;
987
+ page_size: number;
988
+ }>;
989
+ /**
990
+ * DELETE /files/bulk - ลบไฟล์หลายไฟล์
991
+ * Requires authentication
992
+ */
993
+ bulkDelete(ids: string[]): Promise<{
994
+ message: string;
995
+ deleted_count: number;
996
+ }>;
997
+ }
998
+ export { FilesAPI }
999
+ export { FilesAPI as FilesAPI_alias_1 }
1000
+ export { FilesAPI as FilesAPI_alias_2 }
1001
+
1002
+ /**
1003
+ * File Search Parameters
1004
+ * Options for searching and filtering files
1005
+ */
1006
+ declare interface FileSearchParams {
1007
+ entity_type?: string;
1008
+ entity_id?: string;
1009
+ file_category?: string;
1010
+ search?: string;
1011
+ page?: number;
1012
+ page_size?: number;
1013
+ sort_by?: string;
1014
+ sort_order?: 'asc' | 'desc';
1015
+ }
1016
+ export { FileSearchParams }
1017
+ export { FileSearchParams as FileSearchParams_alias_1 }
1018
+ export { FileSearchParams as FileSearchParams_alias_2 }
1019
+
1020
+ /**
1021
+ * File Update Data
1022
+ * Fields that can be updated for a file
1023
+ */
1024
+ declare interface FileUpdateData {
1025
+ description?: string;
1026
+ is_public?: boolean;
1027
+ metadata?: Record<string, any>;
1028
+ entity_field?: string;
1029
+ }
1030
+ export { FileUpdateData }
1031
+ export { FileUpdateData as FileUpdateData_alias_1 }
1032
+ export { FileUpdateData as FileUpdateData_alias_2 }
1033
+
1034
+ /**
1035
+ * File Upload Options
1036
+ * Configuration for uploading a file
1037
+ */
1038
+ declare interface FileUploadOptions {
1039
+ entity_type: string;
1040
+ entity_id: string;
1041
+ entity_field?: string;
1042
+ folder?: string;
1043
+ file_category?: string;
1044
+ description?: string;
1045
+ is_public?: boolean | string;
1046
+ metadata?: Record<string, any>;
1047
+ original_name?: string;
1048
+ mime_type?: string;
1049
+ size?: number;
1050
+ }
1051
+ export { FileUploadOptions }
1052
+ export { FileUploadOptions as FileUploadOptions_alias_1 }
1053
+ export { FileUploadOptions as FileUploadOptions_alias_2 }
1054
+
1055
+ declare class HealthAPI {
1056
+ private readonly axios;
1057
+ constructor(axios: AxiosInstance);
1058
+ /**
1059
+ * Check API health
1060
+ */
1061
+ check(): Promise<any>;
1062
+ /**
1063
+ * Validate if API key is still active
1064
+ */
1065
+ validateApiKey(): Promise<boolean>;
1066
+ }
1067
+ export { HealthAPI }
1068
+ export { HealthAPI as HealthAPI_alias_1 }
1069
+ export { HealthAPI as HealthAPI_alias_2 }
1070
+
1071
+ /**
1072
+ * Event Log Actor Information
1073
+ */
1074
+ declare interface IEventLogActor {
1075
+ type: ActorType;
1076
+ id?: string;
1077
+ name?: string;
1078
+ session_id?: string;
1079
+ ip_address?: string;
1080
+ user_agent?: string;
1081
+ }
1082
+ export { IEventLogActor }
1083
+ export { IEventLogActor as IEventLogActor_alias_1 }
1084
+ export { IEventLogActor as IEventLogActor_alias_2 }
1085
+
1086
+ /**
1087
+ * Event Log Error Information
1088
+ */
1089
+ declare interface IEventLogError {
1090
+ code?: string;
1091
+ message?: string;
1092
+ details?: any;
1093
+ }
1094
+ export { IEventLogError }
1095
+ export { IEventLogError as IEventLogError_alias_1 }
1096
+ export { IEventLogError as IEventLogError_alias_2 }
1097
+
1098
+ /**
1099
+ * Event Log Target Information
1100
+ */
1101
+ declare interface IEventLogTarget {
1102
+ type: string;
1103
+ id?: string;
1104
+ name?: string;
1105
+ }
1106
+ export { IEventLogTarget }
1107
+ export { IEventLogTarget as IEventLogTarget_alias_1 }
1108
+ export { IEventLogTarget as IEventLogTarget_alias_2 }
1109
+
1110
+ declare class LineAPI {
1111
+ private readonly axios;
1112
+ constructor(axios: AxiosInstance);
1113
+ /**
1114
+ * ส่งข้อความ text ไปยัง user
1115
+ *
1116
+ * @example
1117
+ * ```typescript
1118
+ * const result = await authClient.line.sendTextMessage({
1119
+ * userId: 'user-123',
1120
+ * message: 'สวัสดีครับ! ยินดีต้อนรับ'
1121
+ * });
1122
+ * ```
1123
+ */
1124
+ sendTextMessage(request: SendTextMessageRequest): Promise<LineMessageResponse>;
1125
+ /**
1126
+ * ส่ง sticker ไปยัง user
1127
+ *
1128
+ * @example
1129
+ * ```typescript
1130
+ * const result = await authClient.line.sendSticker({
1131
+ * userId: 'user-123',
1132
+ * packageId: '11537',
1133
+ * stickerId: '52002734'
1134
+ * });
1135
+ * ```
1136
+ */
1137
+ sendSticker(request: SendStickerRequest): Promise<LineMessageResponse>;
1138
+ /**
1139
+ * ส่งรูปภาพไปยัง user
1140
+ *
1141
+ * @example
1142
+ * ```typescript
1143
+ * const result = await authClient.line.sendImage({
1144
+ * userId: 'user-123',
1145
+ * originalContentUrl: 'https://example.com/image.jpg',
1146
+ * previewImageUrl: 'https://example.com/preview.jpg'
1147
+ * });
1148
+ * ```
1149
+ */
1150
+ sendImage(request: SendImageRequest): Promise<LineMessageResponse>;
1151
+ /**
1152
+ * ส่งหลายข้อความพร้อมกัน (สูงสุด 5 ข้อความ)
1153
+ *
1154
+ * @example
1155
+ * ```typescript
1156
+ * const result = await authClient.line.sendMessages({
1157
+ * userId: 'user-123',
1158
+ * messages: [
1159
+ * { type: 'text', text: 'ข้อความแรก' },
1160
+ * { type: 'sticker', packageId: '11537', stickerId: '52002734' },
1161
+ * { type: 'text', text: 'ข้อความสุดท้าย' }
1162
+ * ]
1163
+ * });
1164
+ * ```
1165
+ */
1166
+ sendMessages(request: SendMessagesRequest): Promise<LineMessageResponse>;
1167
+ /**
1168
+ * ส่ง notification แบบ high-level (มี title, icon และ action URL)
1169
+ *
1170
+ * @example
1171
+ * ```typescript
1172
+ * const result = await authClient.line.sendNotification({
1173
+ * userId: 'user-123',
1174
+ * title: 'งานใหม่ได้รับมอบหมาย',
1175
+ * message: 'คุณได้รับมอบหมายงาน: ทำรายงานประจำเดือน',
1176
+ * type: 'info',
1177
+ * action_url: 'https://app.example.com/tasks/123',
1178
+ * priority: 'high'
1179
+ * });
1180
+ * ```
1181
+ */
1182
+ sendNotification(request: SendNotificationRequest): Promise<LineMessageResponse>;
1183
+ /**
1184
+ * ตรวจสอบว่า user สามารถรับข้อความ LINE ได้หรือไม่
1185
+ *
1186
+ * @example
1187
+ * ```typescript
1188
+ * const result = await authClient.line.checkMessagingAvailability('user-123');
1189
+ * if (result.data?.canReceiveMessages) {
1190
+ * console.log('User can receive LINE messages');
1191
+ * }
1192
+ * ```
1193
+ */
1194
+ checkMessagingAvailability(userId: string): Promise<LineMessagingAvailabilityResponse>;
1195
+ }
1196
+ export { LineAPI }
1197
+ export { LineAPI as LineAPI_alias_1 }
1198
+ export { LineAPI as LineAPI_alias_2 }
1199
+
1200
+ declare interface LineMessagePayload {
1201
+ type: 'text' | 'image' | 'video' | 'audio' | 'file' | 'location' | 'sticker';
1202
+ text?: string;
1203
+ originalContentUrl?: string;
1204
+ previewImageUrl?: string;
1205
+ title?: string;
1206
+ address?: string;
1207
+ latitude?: number;
1208
+ longitude?: number;
1209
+ packageId?: string;
1210
+ stickerId?: string;
1211
+ }
1212
+ export { LineMessagePayload }
1213
+ export { LineMessagePayload as LineMessagePayload_alias_1 }
1214
+ export { LineMessagePayload as LineMessagePayload_alias_2 }
1215
+
1216
+ declare interface LineMessageResponse {
1217
+ success: boolean;
1218
+ data?: {
1219
+ messageSent: boolean;
1220
+ };
1221
+ message?: string;
1222
+ errors?: string[];
1223
+ timestamp: string;
1224
+ }
1225
+ export { LineMessageResponse }
1226
+ export { LineMessageResponse as LineMessageResponse_alias_1 }
1227
+ export { LineMessageResponse as LineMessageResponse_alias_2 }
1228
+
1229
+ declare interface LineMessagingAvailabilityResponse {
1230
+ success: boolean;
1231
+ data?: {
1232
+ canReceiveMessages: boolean;
1233
+ lineUserId?: string;
1234
+ };
1235
+ message?: string;
1236
+ errors?: string[];
1237
+ timestamp: string;
1238
+ }
1239
+ export { LineMessagingAvailabilityResponse }
1240
+ export { LineMessagingAvailabilityResponse as LineMessagingAvailabilityResponse_alias_1 }
1241
+ export { LineMessagingAvailabilityResponse as LineMessagingAvailabilityResponse_alias_2 }
1242
+
1243
+ declare class Logger {
1244
+ private config;
1245
+ private shouldLog;
1246
+ debug(...args: any[]): void;
1247
+ info(...args: any[]): void;
1248
+ warn(...args: any[]): void;
1249
+ error(...args: any[]): void;
1250
+ /**
1251
+ * อัพเดท logging config
1252
+ *
1253
+ * @param config - Partial config เพื่อ merge กับ config ปัจจุบัน
1254
+ */
1255
+ setConfig(config: Partial<LoggerConfig>): void;
1256
+ /**
1257
+ * ตรวจสอบว่า logging เปิดอยู่หรือไม่
1258
+ */
1259
+ isEnabled(): boolean;
1260
+ /**
1261
+ * ดู log level ปัจจุบัน
1262
+ */
1263
+ getLogLevel(): LogLevel;
1264
+ }
1265
+
1266
+ export declare const logger: Logger;
1267
+
1268
+ declare interface LoggerConfig {
1269
+ enabled: boolean;
1270
+ logLevel: LogLevel;
1271
+ }
1272
+
1273
+ /**
1274
+ * Logger Utility
1275
+ *
1276
+ * @description Centralized logging utility for Auth SDK
1277
+ * Supports different log levels and enable/disable via config
1278
+ *
1279
+ * @example
1280
+ * ```typescript
1281
+ * // ปิด log ทั้งหมด
1282
+ * const client = new AuthClient({ apiKey: '...', logging: false });
1283
+ *
1284
+ * // เปิด log เฉพาะ warn ขึ้นไป
1285
+ * const client = new AuthClient({ apiKey: '...', logging: { enabled: true, level: 'warn' } });
1286
+ *
1287
+ * // เปลี่ยน config ตอน runtime
1288
+ * import { logger } from '@win-portal/auth-sdk';
1289
+ * logger.setConfig({ enabled: false });
1290
+ * ```
1291
+ */
1292
+ export declare type LogLevel = 'debug' | 'info' | 'warn' | 'error';
1293
+
1294
+ /**
1295
+ * Move Organization Request - ข้อมูลสำหรับย้าย organization ไป parent ใหม่
1296
+ *
1297
+ * Structurally identical to `@win-portal/shared` `MoveOrganizationRequestDto`.
1298
+ * Kept local so api-extractor can inline the shape into the published dts
1299
+ * without retaining a reference to `@win-portal/shared`.
1300
+ *
1301
+ * @example
1302
+ * ```json
1303
+ * { "new_parent_id": "org-456" }
1304
+ * ```
1305
+ *
1306
+ * @example Root level
1307
+ * ```json
1308
+ * { "new_parent_id": null }
1309
+ * ```
1310
+ */
1311
+ declare interface MoveOrganizationRequest {
1312
+ new_parent_id: string | null;
1313
+ }
1314
+ export { MoveOrganizationRequest }
1315
+ export { MoveOrganizationRequest as MoveOrganizationRequest_alias_1 }
1316
+ export { MoveOrganizationRequest as MoveOrganizationRequest_alias_2 }
1317
+
1318
+ /**
1319
+ * Organization Types
1320
+ */
1321
+ /**
1322
+ * Organization Entity
1323
+ */
1324
+ declare interface Organization {
1325
+ id: string;
1326
+ name: string;
1327
+ code: string;
1328
+ description?: string;
1329
+ type: OrganizationType | string;
1330
+ parent_id?: string;
1331
+ organization_id: string;
1332
+ department_id?: string;
1333
+ position_id?: string;
1334
+ level: number;
1335
+ report_to_position_id?: string;
1336
+ logo_file_id?: string;
1337
+ total_users?: number;
1338
+ total_departments?: number;
1339
+ total_positions?: number;
1340
+ status: string;
1341
+ is_active: boolean;
1342
+ created_at: string;
1343
+ updated_at: string;
1344
+ parent?: Organization;
1345
+ organization?: Organization;
1346
+ department?: Organization;
1347
+ position?: Organization;
1348
+ report_to_position?: Organization;
1349
+ }
1350
+ export { Organization }
1351
+ export { Organization as Organization_alias_1 }
1352
+ export { Organization as Organization_alias_2 }
1353
+
1354
+ declare interface OrganizationAdvancedFilters {
1355
+ status?: string[];
1356
+ type?: string[];
1357
+ parent_id?: string;
1358
+ organization_id?: string;
1359
+ department_id?: string;
1360
+ code?: string;
1361
+ level?: number;
1362
+ is_active?: boolean;
1363
+ }
1364
+ export { OrganizationAdvancedFilters }
1365
+ export { OrganizationAdvancedFilters as OrganizationAdvancedFilters_alias_1 }
1366
+ export { OrganizationAdvancedFilters as OrganizationAdvancedFilters_alias_2 }
1367
+
1368
+ declare class OrganizationAPI {
1369
+ private readonly axios;
1370
+ constructor(axios: AxiosInstance);
1371
+ /**
1372
+ * Search organizations with pagination and filters
1373
+ */
1374
+ search(params?: OrganizationSearchParams): Promise<ApiPaginatedResponse<Organization>>;
1375
+ /**
1376
+ * Get organization by ID
1377
+ */
1378
+ get(id: string): Promise<Organization>;
1379
+ /**
1380
+ * Find organization by code
1381
+ *
1382
+ * @description ค้นหาองค์กรด้วย code ที่ unique
1383
+ *
1384
+ * @example
1385
+ * ```typescript
1386
+ * const org = await authClient.organization.findByCode("WIN-CORP");
1387
+ * if (org) {
1388
+ * console.log(org.name); // "บริษัท วิน คอร์ปอเรชั่น จำกัด"
1389
+ * }
1390
+ * ```
1391
+ */
1392
+ findByCode(code: string): Promise<Organization | null>;
1393
+ /**
1394
+ * Create a new organization
1395
+ */
1396
+ create(data: CreateOrganizationRequest): Promise<Organization>;
1397
+ /**
1398
+ * Bulk create organizations (เร็วกว่า loop create ทีละรายการ)
1399
+ *
1400
+ * @description สร้างองค์กรหลายรายการในครั้งเดียว ต้องเรียง parent ก่อน child
1401
+ * หรือระบุ id ให้ parent เพื่อให้ child อ้างอิง parent_id ได้
1402
+ *
1403
+ * @example
1404
+ * ```typescript
1405
+ * const result = await authClient.organization.bulkCreate({
1406
+ * organizations: [
1407
+ * { name: "Group A", code: "GRP-A", type: "group", id: "uuid-1" },
1408
+ * { name: "Company 1", code: "CO-1", type: "company", parent_id: "uuid-1", id: "uuid-2" },
1409
+ * { name: "Dept IT", code: "IT", type: "department", parent_id: "uuid-2" },
1410
+ * ],
1411
+ * });
1412
+ * console.log(result.created); // 3
1413
+ * ```
1414
+ */
1415
+ bulkCreate(data: BulkCreateOrganizationRequest): Promise<BulkCreateOrganizationResponse>;
1416
+ /**
1417
+ * Update organization
1418
+ */
1419
+ update(id: string, data: UpdateOrganizationRequest): Promise<Organization>;
1420
+ /**
1421
+ * Delete organization
1422
+ */
1423
+ delete(id: string): Promise<boolean>;
1424
+ /**
1425
+ * Get organization users
1426
+ * @param includeDescendants If true, returns users from all descendant organizations recursively
1427
+ */
1428
+ getUsers(id: string, includeDescendants?: boolean): Promise<User[]>;
1429
+ /**
1430
+ * Get ancestors (parent organizations at all levels)
1431
+ */
1432
+ getAncestors(id: string, includeRoot?: boolean): Promise<Organization[]>;
1433
+ /**
1434
+ * Get immediate supervisor/parent organization
1435
+ */
1436
+ getDirectSupervisor(id: string): Promise<Organization | null>;
1437
+ /**
1438
+ * Get full path from root to organization
1439
+ */
1440
+ getPath(id: string): Promise<Organization[]>;
1441
+ /**
1442
+ * Get reporting line (hierarchical and functional)
1443
+ */
1444
+ getReportingLine(id: string): Promise<ReportingLineResponse>;
1445
+ /**
1446
+ * Get sibling organizations (same parent)
1447
+ */
1448
+ getSiblings(id: string, includeSelf?: boolean): Promise<Organization[]>;
1449
+ /**
1450
+ * Get organization level
1451
+ */
1452
+ getLevel(id: string): Promise<OrganizationLevelResponse>;
1453
+ /**
1454
+ * Get lowest common ancestor of two organizations
1455
+ */
1456
+ getCommonAncestor(orgA: string, orgB: string): Promise<Organization | null>;
1457
+ /**
1458
+ * Check if an organization is an ancestor of another
1459
+ */
1460
+ isAncestorOf(ancestorId: string, descendantId: string): Promise<boolean>;
1461
+ /**
1462
+ * Get organization hierarchy
1463
+ *
1464
+ * @description ดึง hierarchy tree ขององค์กรทั้งหมด หรือเริ่มจาก root ที่ระบุ
1465
+ *
1466
+ * @param rootId - Optional root organization ID. ถ้าไม่ระบุจะดึง hierarchy ทั้งหมด
1467
+ *
1468
+ * @example
1469
+ * ```typescript
1470
+ * // ดึง hierarchy ทั้งหมด
1471
+ * const hierarchy = await authClient.organization.getHierarchy();
1472
+ *
1473
+ * // ดึง hierarchy จาก root ที่ระบุ
1474
+ * const hierarchy = await authClient.organization.getHierarchy("org-root-123");
1475
+ * ```
1476
+ */
1477
+ getHierarchy(rootId?: string): Promise<Organization[]>;
1478
+ /**
1479
+ * Get organization tree (with departments and positions)
1480
+ *
1481
+ * @description ดึงโครงสร้าง tree ขององค์กร รวม departments, positions และ user assignments
1482
+ *
1483
+ * @example
1484
+ * ```typescript
1485
+ * const tree = await authClient.organization.getTree("org-123");
1486
+ * console.log(tree.children); // departments & positions
1487
+ * console.log(tree.total_users); // จำนวนผู้ใช้ทั้งหมด
1488
+ * ```
1489
+ */
1490
+ getTree(id: string): Promise<OrganizationTreeResponse>;
1491
+ /**
1492
+ * Get direct children of organization
1493
+ *
1494
+ * @description ดึงองค์กรลูกตรง (direct children) ขององค์กรที่ระบุ
1495
+ *
1496
+ * @example
1497
+ * ```typescript
1498
+ * const children = await authClient.organization.getChildren("org-123");
1499
+ * ```
1500
+ */
1501
+ getChildren(id: string): Promise<Organization[]>;
1502
+ /**
1503
+ * Get sub-organizations
1504
+ *
1505
+ * @description ดึง sub-organizations ขององค์กรที่ระบุ
1506
+ *
1507
+ * @example
1508
+ * ```typescript
1509
+ * const subOrgs = await authClient.organization.getSubOrganizations("org-123");
1510
+ * ```
1511
+ */
1512
+ getSubOrganizations(id: string): Promise<Organization[]>;
1513
+ /**
1514
+ * Get positions under organization
1515
+ *
1516
+ * @description ดึงรายการตำแหน่ง (position nodes) ทั้งหมดภายใต้องค์กรที่ระบุ
1517
+ *
1518
+ * @example
1519
+ * ```typescript
1520
+ * const positions = await authClient.organization.getPositions("org-123");
1521
+ * console.log(positions.map(p => p.name)); // ["Senior Developer", "Team Lead", ...]
1522
+ * ```
1523
+ */
1524
+ getPositions(id: string): Promise<Organization[]>;
1525
+ /**
1526
+ * Activate organization
1527
+ *
1528
+ * @description เปิดใช้งานองค์กร
1529
+ *
1530
+ * @example
1531
+ * ```typescript
1532
+ * await authClient.organization.activate("org-123");
1533
+ * ```
1534
+ */
1535
+ activate(id: string): Promise<boolean>;
1536
+ /**
1537
+ * Deactivate organization
1538
+ *
1539
+ * @description ปิดใช้งานองค์กร
1540
+ *
1541
+ * @example
1542
+ * ```typescript
1543
+ * await authClient.organization.deactivate("org-123");
1544
+ * ```
1545
+ */
1546
+ deactivate(id: string): Promise<boolean>;
1547
+ /**
1548
+ * Bulk activate organizations
1549
+ *
1550
+ * @description เปิดใช้งานหลายองค์กรพร้อมกัน
1551
+ *
1552
+ * @example
1553
+ * ```typescript
1554
+ * const result = await authClient.organization.bulkActivate(["org-1", "org-2", "org-3"]);
1555
+ * console.log(result.success_count); // 3
1556
+ * ```
1557
+ */
1558
+ bulkActivate(ids: string[]): Promise<BulkOperationResponse>;
1559
+ /**
1560
+ * Bulk deactivate organizations
1561
+ *
1562
+ * @description ปิดใช้งานหลายองค์กรพร้อมกัน
1563
+ *
1564
+ * @example
1565
+ * ```typescript
1566
+ * const result = await authClient.organization.bulkDeactivate(["org-1", "org-2"]);
1567
+ * console.log(result.success_count); // 2
1568
+ * ```
1569
+ */
1570
+ bulkDeactivate(ids: string[]): Promise<BulkOperationResponse>;
1571
+ /**
1572
+ * Bulk delete organizations
1573
+ *
1574
+ * @description ลบหลายองค์กรพร้อมกัน
1575
+ *
1576
+ * @example
1577
+ * ```typescript
1578
+ * const result = await authClient.organization.bulkDelete(["org-1", "org-2"]);
1579
+ * console.log(result.success_count); // 2
1580
+ * ```
1581
+ */
1582
+ bulkDelete(ids: string[]): Promise<BulkOperationResponse>;
1583
+ /**
1584
+ * Clear all organization data
1585
+ *
1586
+ * @description ลบข้อมูลองค์กรทั้งหมด รวมถึง:
1587
+ * - user_position_assignment (เอาข้อมูล position ออกจาก user)
1588
+ * - organization_closure
1589
+ * - organization (company, department, position)
1590
+ * - Nullify organization/position references ใน workflow และ document tables
1591
+ *
1592
+ * รองรับทั้ง JWT และ API Key authentication (สำหรับเรียกจากระบบอื่น)
1593
+ *
1594
+ * @example
1595
+ * ```typescript
1596
+ * const result = await authClient.organization.clearAll();
1597
+ * console.log(result.organizations_deleted); // จำนวนองค์กรที่ลบ
1598
+ * console.log(result.user_position_assignments_deleted); // จำนวน position assignment ที่ลบ
1599
+ * ```
1600
+ */
1601
+ clearAll(): Promise<ClearAllDataResponse>;
1602
+ /**
1603
+ * Rebuild all organization data (รวมทุก fix ในครั้งเดียว)
1604
+ *
1605
+ * @description ใช้หลัง clear-all + create เพื่อให้ข้อมูลครบถ้วน:
1606
+ * 1. fix organization_id ตาม hierarchy
1607
+ * 2. reload organization_closure สำหรับทุก company
1608
+ * 3. reload report_to_position
1609
+ *
1610
+ * @example
1611
+ * ```typescript
1612
+ * await authClient.organization.clearAll();
1613
+ * // ... create organizations ...
1614
+ * const result = await authClient.organization.rebuildAll();
1615
+ * console.log(result.organization_ids_fixed, result.closure_companies_processed);
1616
+ * ```
1617
+ */
1618
+ rebuildAll(): Promise<RebuildAllDataResponse>;
1619
+ /**
1620
+ * Duplicate organization (copy)
1621
+ *
1622
+ * @description คัดลอกองค์กรและ children ทั้งหมด สร้าง organization ใหม่พร้อม hierarchy fields และ closure records
1623
+ *
1624
+ * @example
1625
+ * ```typescript
1626
+ * const duplicated = await authClient.organization.duplicate("org-123");
1627
+ * console.log(duplicated.id); // new organization ID
1628
+ * ```
1629
+ */
1630
+ duplicate(id: string): Promise<Organization>;
1631
+ /**
1632
+ * Move organization to new parent
1633
+ *
1634
+ * @description ย้ายองค์กรไปอยู่ภายใต้ parent ใหม่ อัพเดท hierarchy fields และ closure table อัตโนมัติ
1635
+ * ส่ง `null` เพื่อย้ายไปเป็น root level
1636
+ *
1637
+ * @example
1638
+ * ```typescript
1639
+ * // ย้ายไปอยู่ภายใต้ parent ใหม่
1640
+ * await authClient.organization.move("org-123", { new_parent_id: "org-456" });
1641
+ *
1642
+ * // ย้ายไปเป็น root level
1643
+ * await authClient.organization.move("org-123", { new_parent_id: null });
1644
+ * ```
1645
+ */
1646
+ move(id: string, data: MoveOrganizationRequest): Promise<boolean>;
1647
+ }
1648
+ export { OrganizationAPI }
1649
+ export { OrganizationAPI as OrganizationAPI_alias_1 }
1650
+ export { OrganizationAPI as OrganizationAPI_alias_2 }
1651
+
1652
+ /**
1653
+ * Organization Level Response
1654
+ */
1655
+ declare interface OrganizationLevelResponse {
1656
+ level: number;
1657
+ type: OrganizationType | string;
1658
+ }
1659
+ export { OrganizationLevelResponse }
1660
+ export { OrganizationLevelResponse as OrganizationLevelResponse_alias_1 }
1661
+ export { OrganizationLevelResponse as OrganizationLevelResponse_alias_2 }
1662
+
1663
+ /**
1664
+ * Organization Search Params
1665
+ */
1666
+ declare interface OrganizationSearchParams {
1667
+ page?: number;
1668
+ page_size?: number;
1669
+ search?: string;
1670
+ sort_by?: string;
1671
+ sort_order?: 'asc' | 'desc';
1672
+ advanced?: OrganizationAdvancedFilters;
1673
+ }
1674
+ export { OrganizationSearchParams }
1675
+ export { OrganizationSearchParams as OrganizationSearchParams_alias_1 }
1676
+ export { OrganizationSearchParams as OrganizationSearchParams_alias_2 }
1677
+
1678
+ /**
1679
+ * Organization Tree Node - โหนดใน tree structure
1680
+ *
1681
+ * @note Diverges from @win-portal/shared `OrganizationTreeNodeDto`:
1682
+ * - `type` is widened to `OrganizationType | string` for forward-compat with
1683
+ * future node types returned by the API
1684
+ * - `department_type` is `string` (not the strict `DepartmentType` enum)
1685
+ * - `users` uses the SDK's `UserSummary` (flat positions array) instead of
1686
+ * shared's `UserSummaryDto` (single `primary_position_id` field)
1687
+ */
1688
+ declare interface OrganizationTreeNode {
1689
+ id: string;
1690
+ name: string;
1691
+ code: string;
1692
+ type: OrganizationType | string;
1693
+ children?: OrganizationTreeNode[];
1694
+ department_type?: string;
1695
+ level?: number;
1696
+ users?: UserSummary[];
1697
+ total_users?: number;
1698
+ total_departments?: number;
1699
+ total_positions?: number;
1700
+ }
1701
+ export { OrganizationTreeNode }
1702
+ export { OrganizationTreeNode as OrganizationTreeNode_alias_1 }
1703
+ export { OrganizationTreeNode as OrganizationTreeNode_alias_2 }
1704
+
1705
+ /**
1706
+ * Organization Tree Response - root organization node พร้อม complete tree structure
1707
+ *
1708
+ * @note Inherits the divergence from `OrganizationTreeNode` above (widened
1709
+ * enums and SDK-shaped `users`). Kept local rather than re-exported from shared.
1710
+ */
1711
+ declare interface OrganizationTreeResponse extends OrganizationTreeNode {
1712
+ type: OrganizationType.COMPANY | OrganizationType.GROUP | string;
1713
+ }
1714
+ export { OrganizationTreeResponse }
1715
+ export { OrganizationTreeResponse as OrganizationTreeResponse_alias_1 }
1716
+ export { OrganizationTreeResponse as OrganizationTreeResponse_alias_2 }
1717
+
1718
+ declare enum OrganizationType {
1719
+ GROUP = 'group', // กลุ่มบริษัท (Level 0)
1720
+ COMPANY = 'company', // บริษัท/องค์กรหลัก (alias: ORGANIZATION) (Level 1)
1721
+ BRANCH = 'branch', // สาขา (Level 1.5)
1722
+ DIVISION = 'division', // ฝ่าย (Level 2)
1723
+ DEPARTMENT = 'department', // แผนก (Level 3)
1724
+ SECTION = 'section', // ส่วนงาน (Level 3.5) - ระหว่าง Department กับ Team
1725
+ TEAM = 'team', // ทีม (Level 4)
1726
+ POSITION = 'position', // ตำแหน่งงาน (Level 5)
1727
+ }
1728
+ export { OrganizationType }
1729
+ export { OrganizationType as OrganizationType_alias_1 }
1730
+ export { OrganizationType as OrganizationType_alias_2 }
1731
+
1732
+ declare class OtpAPI {
1733
+ private readonly axios;
1734
+ constructor(axios: AxiosInstance);
1735
+ /**
1736
+ * Send OTP to recipient (SMS or Email)
1737
+ *
1738
+ * @example
1739
+ * ```typescript
1740
+ * // Send SMS OTP
1741
+ * const result = await authClient.otp.sendOTP({
1742
+ * method: 'sms',
1743
+ * recipient: '0812345678',
1744
+ * context: 'login'
1745
+ * });
1746
+ *
1747
+ * console.log('OTP ID:', result.otp_id); // UUID
1748
+ * console.log('Ref Code:', result.ref_code); // OTP-XXXXXX (for tracking)
1749
+ * console.log('Expires at:', result.expires_at);
1750
+ *
1751
+ * // Send Email OTP
1752
+ * const result = await authClient.otp.sendOTP({
1753
+ * method: 'email',
1754
+ * recipient: 'user@example.com',
1755
+ * context: 'verification'
1756
+ * });
1757
+ * ```
1758
+ */
1759
+ sendOTP(request: SendOTPRequest): Promise<SendOTPResponse>;
1760
+ /**
1761
+ * Verify OTP code
1762
+ *
1763
+ * @example
1764
+ * ```typescript
1765
+ * const result = await authClient.otp.verifyOTP({
1766
+ * otp_id: '123e4567-e89b-12d3-a456-426614174000',
1767
+ * code: '123456'
1768
+ * });
1769
+ *
1770
+ * if (result.verified) {
1771
+ * console.log('OTP verified successfully');
1772
+ * }
1773
+ * ```
1774
+ */
1775
+ verifyOTP(request: VerifyOTPRequest): Promise<VerifyOTPResponse>;
1776
+ }
1777
+ export { OtpAPI }
1778
+ export { OtpAPI as OtpAPI_alias_1 }
1779
+ export { OtpAPI as OtpAPI_alias_2 }
1780
+
1781
+ /**
1782
+ * Pagination Meta Interface
1783
+ *
1784
+ * @description Interface สำหรับ metadata ที่ส่งกลับพร้อมกับ paginated response
1785
+ * รวมถึงข้อมูลการแบ่งหน้าและ navigation
1786
+ *
1787
+ * @properties
1788
+ * - page: หมายเลขหน้าปัจจุบัน (required)
1789
+ * - limit: จำนวนรายการต่อหน้า (required)
1790
+ * - total: จำนวนรายการทั้งหมด (required)
1791
+ * - total_pages: จำนวนหน้าทั้งหมด (required)
1792
+ * - has_next: มีหน้าถัดไปหรือไม่ (required)
1793
+ * - has_prev: มีหน้าก่อนหน้าหรือไม่ (required)
1794
+ * - start_index: index เริ่มต้นของหน้านี้ (required)
1795
+ * - end_index: index สุดท้ายของหน้านี้ (required)
1796
+ *
1797
+ * @example
1798
+ * ```typescript
1799
+ * const paginationMeta: PaginationMeta = {
1800
+ * page: 2,
1801
+ * limit: 20,
1802
+ * total: 100,
1803
+ * total_pages: 5,
1804
+ * has_next: true,
1805
+ * has_prev: true,
1806
+ * start_index: 21,
1807
+ * end_index: 40
1808
+ * }
1809
+ *
1810
+ * // First page
1811
+ * const firstPageMeta: PaginationMeta = {
1812
+ * page: 1,
1813
+ * limit: 10,
1814
+ * total: 25,
1815
+ * total_pages: 3,
1816
+ * has_next: true,
1817
+ * has_prev: false,
1818
+ * start_index: 1,
1819
+ * end_index: 10
1820
+ * }
1821
+ * ```
1822
+ *
1823
+ * Usage:
1824
+ * import { PaginationMeta } from '@win-portal/shared/interfaces/helpers/pagination-meta.interface';
1825
+ */
1826
+ declare interface PaginationMeta {
1827
+ page: number;
1828
+ limit: number;
1829
+ total: number;
1830
+ total_pages: number;
1831
+ has_next: boolean;
1832
+ has_prev: boolean;
1833
+ start_index: number;
1834
+ end_index: number;
1835
+ }
1836
+ export { PaginationMeta }
1837
+ export { PaginationMeta as PaginationMeta_alias_1 }
1838
+
1839
+ /**
1840
+ * Permission Types
1841
+ *
1842
+ * @description SDK-friendly shapes for permission and permission category operations.
1843
+ * Names drop the `Dto` suffix vs @win-portal/shared; structure is intentionally a
1844
+ * relaxed subset of the server DTOs (optional fields, string-widened enums).
1845
+ */
1846
+ /**
1847
+ * Permission Entity
1848
+ */
1849
+ declare interface Permission {
1850
+ id: string;
1851
+ name: string;
1852
+ key: string;
1853
+ description?: string;
1854
+ resource: string;
1855
+ category_id?: string;
1856
+ application_id?: string;
1857
+ is_system?: boolean;
1858
+ sort_order?: number;
1859
+ status?: string;
1860
+ created_at: string;
1861
+ updated_at: string;
1862
+ }
1863
+ export { Permission }
1864
+ export { Permission as Permission_alias_1 }
1865
+ export { Permission as Permission_alias_2 }
1866
+
1867
+ declare class PermissionAPI {
1868
+ private readonly axios;
1869
+ constructor(axios: AxiosInstance);
1870
+ /**
1871
+ * Clear all permissions for current application (hard delete)
1872
+ *
1873
+ * @description ลบสิทธิ์ทั้งหมดตาม application_id จาก RequestContext (API key/context)
1874
+ * ใช้สำหรับ migrate - ไม่ใช้ DTO, ดึง application_id จาก context อัตโนมัติ
1875
+ *
1876
+ * @example
1877
+ * ```typescript
1878
+ * const result = await authClient.permission.clear();
1879
+ * console.log(result.permissions_deleted, result.role_permissions_deleted);
1880
+ * ```
1881
+ */
1882
+ clear(): Promise<PermissionClearResponse>;
1883
+ /**
1884
+ * Search permissions with pagination and filters
1885
+ */
1886
+ search(params?: PermissionSearchParams): Promise<ApiPaginatedResponse<Permission>>;
1887
+ /**
1888
+ * Get permission by ID
1889
+ */
1890
+ get(id: string): Promise<Permission | null>;
1891
+ /**
1892
+ * Create a new permission
1893
+ */
1894
+ create(data: CreatePermissionRequest): Promise<Permission>;
1895
+ /**
1896
+ * Bulk create permissions ในครั้งเดียว
1897
+ *
1898
+ * @description สร้างสิทธิ์หลายรายการในครั้งเดียว ทุก permission ต้องมี category_id ที่มีอยู่แล้วในระบบ
1899
+ *
1900
+ * @example
1901
+ * ```typescript
1902
+ * const result = await authClient.permission.bulkCreate({
1903
+ * permissions: [
1904
+ * { category_id: "cat-uuid", name: "Create", key: "create", description: "..." },
1905
+ * { category_id: "cat-uuid", name: "Read", key: "read", description: "..." },
1906
+ * ],
1907
+ * });
1908
+ * console.log(result.created); // 2
1909
+ * ```
1910
+ */
1911
+ bulkCreate(data: BulkCreatePermissionRequest): Promise<BulkCreateResponse>;
1912
+ /**
1913
+ * Update permission
1914
+ */
1915
+ update(id: string, data: UpdatePermissionRequest): Promise<Permission>;
1916
+ /**
1917
+ * Delete permission
1918
+ */
1919
+ delete(id: string): Promise<boolean>;
1920
+ /**
1921
+ * Activate permission
1922
+ */
1923
+ activate(id: string): Promise<boolean>;
1924
+ /**
1925
+ * Deactivate permission
1926
+ */
1927
+ deactivate(id: string): Promise<boolean>;
1928
+ }
1929
+ export { PermissionAPI }
1930
+ export { PermissionAPI as PermissionAPI_alias_1 }
1931
+ export { PermissionAPI as PermissionAPI_alias_2 }
1932
+
1933
+ /**
1934
+ * Permission Category Entity
1935
+ */
1936
+ declare interface PermissionCategory {
1937
+ id: string;
1938
+ name: string;
1939
+ key: string;
1940
+ description?: string;
1941
+ resource?: string;
1942
+ application_id: string;
1943
+ parent_id?: string;
1944
+ is_system?: boolean;
1945
+ sort_order?: number;
1946
+ level?: number;
1947
+ status?: string;
1948
+ created_at: string;
1949
+ updated_at: string;
1950
+ permissions?: Permission[];
1951
+ }
1952
+ export { PermissionCategory }
1953
+ export { PermissionCategory as PermissionCategory_alias_1 }
1954
+ export { PermissionCategory as PermissionCategory_alias_2 }
1955
+
1956
+ declare class PermissionCategoryAPI {
1957
+ private readonly axios;
1958
+ constructor(axios: AxiosInstance);
1959
+ /**
1960
+ * Clear all permission categories for current application (hard delete)
1961
+ *
1962
+ * @description ลบหมวดหมู่สิทธิ์ทั้งหมดตาม application_id จาก RequestContext (API key/context)
1963
+ * ใช้สำหรับ migrate - ไม่ใช้ DTO, ดึง application_id จาก context อัตโนมัติ
1964
+ *
1965
+ * @example
1966
+ * ```typescript
1967
+ * const result = await authClient.permissionCategory.clear();
1968
+ * console.log(result.permission_categories_deleted, result.permissions_deleted);
1969
+ * ```
1970
+ */
1971
+ clear(): Promise<PermissionCategoryClearResponse>;
1972
+ /**
1973
+ * Search permission categories with pagination and filters
1974
+ */
1975
+ search(params?: PermissionCategorySearchParams): Promise<ApiPaginatedResponse<PermissionCategory>>;
1976
+ /**
1977
+ * Get permission category by ID
1978
+ */
1979
+ get(id: string): Promise<PermissionCategory>;
1980
+ /**
1981
+ * Create a new permission category (พร้อม permissions ได้)
1982
+ *
1983
+ * @note application_id ไม่ต้องส่งเมื่อเรียกจาก app context - API จะ inject อัตโนมัติ
1984
+ */
1985
+ create(data: CreatePermissionCategoryRequest): Promise<PermissionCategory>;
1986
+ /**
1987
+ * Bulk create permission categories พร้อม permissions ในครั้งเดียว
1988
+ *
1989
+ * @description สร้างหมวดหมู่สิทธิ์หลายรายการพร้อม permissions ในครั้งเดียว
1990
+ * ต้องเรียง parent ก่อน child หรือระบุ id ให้ parent เพื่อให้ child อ้างอิง parent_id ได้
1991
+ *
1992
+ * @note application_id ไม่ต้องส่ง - API จะ inject อัตโนมัติจาก API key หรือ RequestContextService
1993
+ *
1994
+ * @example
1995
+ * ```typescript
1996
+ * // เรียกจาก app context (API key) - application_id จะถูก inject อัตโนมัติ
1997
+ * const result = await authClient.permissionCategory.bulkCreate({
1998
+ * permission_categories: [
1999
+ * {
2000
+ * id: "cat-users",
2001
+ * key: "users",
2002
+ * name: "User Management",
2003
+ * resource: "users",
2004
+ * permissions: [
2005
+ * { name: "Create User", key: "create", description: "..." },
2006
+ * { name: "Read User", key: "read", description: "..." },
2007
+ * ],
2008
+ * },
2009
+ * {
2010
+ * key: "user_profile",
2011
+ * name: "User Profile",
2012
+ * parent_id: "cat-users",
2013
+ * permissions: [{ name: "Edit Profile", key: "edit", description: "..." }],
2014
+ * },
2015
+ * ],
2016
+ * });
2017
+ * console.log(result.created); // 2
2018
+ * ```
2019
+ */
2020
+ bulkCreate(data: BulkCreatePermissionCategoryRequest): Promise<BulkCreateResponse>;
2021
+ /**
2022
+ * Update permission category
2023
+ */
2024
+ update(id: string, data: UpdatePermissionCategoryRequest): Promise<PermissionCategory>;
2025
+ /**
2026
+ * Delete permission category
2027
+ */
2028
+ delete(id: string): Promise<boolean>;
2029
+ }
2030
+ export { PermissionCategoryAPI }
2031
+ export { PermissionCategoryAPI as PermissionCategoryAPI_alias_1 }
2032
+ export { PermissionCategoryAPI as PermissionCategoryAPI_alias_2 }
2033
+
2034
+ /**
2035
+ * Permission Category Clear Response - ผลลัพธ์จากการลบ permission categories ตาม application_id
2036
+ * ใช้ application_id จาก RequestContext (API key/context)
2037
+ */
2038
+ declare interface PermissionCategoryClearResponse {
2039
+ permission_categories_deleted: number;
2040
+ permissions_deleted: number;
2041
+ role_permissions_deleted: number;
2042
+ }
2043
+ export { PermissionCategoryClearResponse }
2044
+ export { PermissionCategoryClearResponse as PermissionCategoryClearResponse_alias_1 }
2045
+ export { PermissionCategoryClearResponse as PermissionCategoryClearResponse_alias_2 }
2046
+
2047
+ /**
2048
+ * Permission Category Search Params
2049
+ */
2050
+ declare interface PermissionCategorySearchParams {
2051
+ search?: string;
2052
+ page?: number;
2053
+ page_size?: number;
2054
+ sort_by?: string;
2055
+ sort_order?: 'asc' | 'desc';
2056
+ advanced?: {
2057
+ application_id?: string;
2058
+ is_active?: boolean;
2059
+ color?: string;
2060
+ icon?: string;
2061
+ };
2062
+ }
2063
+ export { PermissionCategorySearchParams }
2064
+ export { PermissionCategorySearchParams as PermissionCategorySearchParams_alias_1 }
2065
+ export { PermissionCategorySearchParams as PermissionCategorySearchParams_alias_2 }
2066
+
2067
+ /**
2068
+ * Permission Clear Response - ผลลัพธ์จากการลบ permissions ตาม application_id
2069
+ * ใช้ application_id จาก RequestContext (API key/context)
2070
+ */
2071
+ declare interface PermissionClearResponse {
2072
+ permissions_deleted: number;
2073
+ role_permissions_deleted: number;
2074
+ }
2075
+ export { PermissionClearResponse }
2076
+ export { PermissionClearResponse as PermissionClearResponse_alias_1 }
2077
+ export { PermissionClearResponse as PermissionClearResponse_alias_2 }
2078
+
2079
+ /**
2080
+ * Permission Search Params
2081
+ */
2082
+ declare interface PermissionSearchParams {
2083
+ search?: string;
2084
+ page?: number;
2085
+ page_size?: number;
2086
+ sort_by?: string;
2087
+ sort_order?: 'asc' | 'desc';
2088
+ advanced?: {
2089
+ status?: string;
2090
+ is_active?: boolean;
2091
+ key?: string;
2092
+ resource?: string;
2093
+ category_id?: string;
2094
+ application_id?: string;
2095
+ is_system?: boolean;
2096
+ };
2097
+ }
2098
+ export { PermissionSearchParams }
2099
+ export { PermissionSearchParams as PermissionSearchParams_alias_1 }
2100
+ export { PermissionSearchParams as PermissionSearchParams_alias_2 }
2101
+
2102
+ declare class PortalApiClient {
2103
+ private readonly axios;
2104
+ readonly email: EmailAPI;
2105
+ readonly eventLog: EventLogApi;
2106
+ readonly files: FilesAPI;
2107
+ readonly health: HealthAPI;
2108
+ readonly line: LineAPI;
2109
+ readonly organization: OrganizationAPI;
2110
+ readonly otp: OtpAPI;
2111
+ readonly permission: PermissionAPI;
2112
+ readonly permissionCategory: PermissionCategoryAPI;
2113
+ readonly role: RoleAPI;
2114
+ readonly systemConfig: SystemConfigAPI;
2115
+ readonly todo: TodoAPI;
2116
+ readonly user: UserAPI;
2117
+ readonly webhook: WebhookAPI;
2118
+ readonly workflow: WorkflowAPI;
2119
+ constructor(config: PortalApiConfig);
2120
+ get<T = any>(url: string, config?: AxiosRequestConfig): Promise<AxiosResponse<T, any>>;
2121
+ post<T = any>(url: string, data?: any, config?: AxiosRequestConfig): Promise<AxiosResponse<T, any>>;
2122
+ put<T = any>(url: string, data?: any, config?: AxiosRequestConfig): Promise<AxiosResponse<T, any>>;
2123
+ patch<T = any>(url: string, data?: any, config?: AxiosRequestConfig): Promise<AxiosResponse<T, any>>;
2124
+ delete<T = any>(url: string, config?: AxiosRequestConfig): Promise<AxiosResponse<T, any>>;
2125
+ }
2126
+ export { PortalApiClient }
2127
+ export { PortalApiClient as PortalApiClient_alias_1 }
2128
+
2129
+ declare interface PortalApiConfig {
2130
+ apiUrl: string;
2131
+ getToken: () => string | null;
2132
+ apiKey?: string;
2133
+ timeout?: number;
2134
+ }
2135
+ export { PortalApiConfig }
2136
+ export { PortalApiConfig as PortalApiConfig_alias_1 }
2137
+
2138
+ /**
2139
+ * Rebuild All Response - ผลลัพธ์จากการ rebuild ข้อมูลองค์กรทั้งหมด
2140
+ *
2141
+ * @description ใช้กับ organization.rebuildAll() - รวม fix organization_id + reload closure + report_to_position
2142
+ */
2143
+ declare interface RebuildAllDataResponse {
2144
+ organization_ids_fixed: number;
2145
+ closure_companies_processed: number;
2146
+ report_to_position_updated: number;
2147
+ execution_time_ms: number;
2148
+ }
2149
+ export { RebuildAllDataResponse }
2150
+ export { RebuildAllDataResponse as RebuildAllDataResponse_alias_1 }
2151
+ export { RebuildAllDataResponse as RebuildAllDataResponse_alias_2 }
2152
+
2153
+ /**
2154
+ * Reporting Line Response
2155
+ */
2156
+ declare interface ReportingLineResponse {
2157
+ hierarchical: Organization[];
2158
+ functional: Organization | null;
2159
+ }
2160
+ export { ReportingLineResponse }
2161
+ export { ReportingLineResponse as ReportingLineResponse_alias_1 }
2162
+ export { ReportingLineResponse as ReportingLineResponse_alias_2 }
2163
+
2164
+ /**
2165
+ * Role Types for Auth SDK
2166
+ *
2167
+ * @description SDK-friendly shapes for role operations. Names drop the `Dto`
2168
+ * suffix vs @win-portal/shared; structure is a relaxed subset of the server
2169
+ * DTOs (`Role` is a simplified view of `RoleResponseDto`).
2170
+ */
2171
+ /**
2172
+ * Role - ข้อมูลบทบาทพื้นฐาน
2173
+ * Matches RoleResponseDto from @win-portal/shared
2174
+ */
2175
+ declare interface Role {
2176
+ id: string;
2177
+ name: string;
2178
+ code: string;
2179
+ description?: string;
2180
+ is_system: boolean;
2181
+ status: string;
2182
+ created_at: Date | string;
2183
+ updated_at: Date | string;
2184
+ }
2185
+ export { Role }
2186
+ export { Role as Role_alias_1 }
2187
+ export { Role as Role_alias_2 }
2188
+
2189
+ declare class RoleAPI {
2190
+ private readonly axios;
2191
+ constructor(axios: AxiosInstance);
2192
+ /**
2193
+ * Search roles with pagination and filters
2194
+ *
2195
+ * @example
2196
+ * ```typescript
2197
+ * const result = await authClient.role.search({
2198
+ * search: "Admin",
2199
+ * page: 1,
2200
+ * limit: 20,
2201
+ * sort_by: "created_at",
2202
+ * sort_order: "desc"
2203
+ * });
2204
+ * ```
2205
+ */
2206
+ search(params?: RoleSearchParams): Promise<ApiPaginatedResponse<Role>>;
2207
+ /**
2208
+ * Get role by ID
2209
+ *
2210
+ * @example
2211
+ * ```typescript
2212
+ * const role = await authClient.role.get("role-123");
2213
+ * ```
2214
+ */
2215
+ get(roleId: string): Promise<Role>;
2216
+ /**
2217
+ * Create a new role
2218
+ *
2219
+ * @example
2220
+ * ```typescript
2221
+ * const newRole = await authClient.role.create({
2222
+ * name: "ผู้ดูแลระบบ",
2223
+ * code: "ADMIN",
2224
+ * description: "บทบาทสำหรับผู้ดูแลระบบ"
2225
+ * });
2226
+ * ```
2227
+ */
2228
+ create(data: CreateRoleRequest): Promise<Role>;
2229
+ /**
2230
+ * Update role
2231
+ *
2232
+ * @example
2233
+ * ```typescript
2234
+ * const updatedRole = await authClient.role.update("role-123", {
2235
+ * name: "ผู้ดูแลระบบหลัก",
2236
+ * description: "บทบาทสำหรับผู้ดูแลระบบหลัก"
2237
+ * });
2238
+ * ```
2239
+ */
2240
+ update(roleId: string, data: UpdateRoleRequest): Promise<Role>;
2241
+ /**
2242
+ * Clear all roles for current application (hard delete)
2243
+ *
2244
+ * @description ลบบทบาททั้งหมดตาม application_id จาก RequestContext (API key/context)
2245
+ * ใช้สำหรับ migrate - ไม่ใช้ DTO, ดึง application_id จาก context อัตโนมัติ
2246
+ *
2247
+ * @example
2248
+ * ```typescript
2249
+ * const result = await authClient.role.clear();
2250
+ * console.log(result.roles_deleted, result.role_permissions_deleted);
2251
+ * ```
2252
+ */
2253
+ clear(): Promise<RoleClearResponse>;
2254
+ /**
2255
+ * Delete role
2256
+ *
2257
+ * @example
2258
+ * ```typescript
2259
+ * await authClient.role.delete("role-123");
2260
+ * ```
2261
+ */
2262
+ delete(roleId: string): Promise<boolean>;
2263
+ /**
2264
+ * Activate role
2265
+ *
2266
+ * @example
2267
+ * ```typescript
2268
+ * await authClient.role.activate("role-123");
2269
+ * ```
2270
+ */
2271
+ activate(roleId: string): Promise<boolean>;
2272
+ /**
2273
+ * Deactivate role
2274
+ *
2275
+ * @example
2276
+ * ```typescript
2277
+ * await authClient.role.deactivate("role-123");
2278
+ * ```
2279
+ */
2280
+ deactivate(roleId: string): Promise<boolean>;
2281
+ /**
2282
+ * Get role users
2283
+ *
2284
+ * @description ดึงรายการผู้ใช้ทั้งหมดที่มีบทบาทนี้
2285
+ *
2286
+ * @example
2287
+ * ```typescript
2288
+ * const users = await authClient.role.getUsers("role-123");
2289
+ * console.log(users.map(u => u.email));
2290
+ * ```
2291
+ */
2292
+ getUsers(roleId: string): Promise<User[]>;
2293
+ /**
2294
+ * Assign users to role
2295
+ *
2296
+ * @description มอบหมายผู้ใช้ให้บทบาท (เพิ่มเข้าไป ไม่ลบของเดิม)
2297
+ *
2298
+ * @example
2299
+ * ```typescript
2300
+ * await authClient.role.assignUsers("role-123", ["user-001", "user-002"]);
2301
+ * ```
2302
+ */
2303
+ assignUsers(roleId: string, userIds: string[]): Promise<boolean>;
2304
+ /**
2305
+ * Unassign users from role
2306
+ *
2307
+ * @description ยกเลิกผู้ใช้จากบทบาท
2308
+ *
2309
+ * @example
2310
+ * ```typescript
2311
+ * await authClient.role.unassignUsers("role-123", ["user-001"]);
2312
+ * ```
2313
+ */
2314
+ unassignUsers(roleId: string, userIds: string[]): Promise<boolean>;
2315
+ /**
2316
+ * Get role permissions
2317
+ *
2318
+ * @description ดึงรายการสิทธิ์ทั้งหมดของบทบาท
2319
+ *
2320
+ * @example
2321
+ * ```typescript
2322
+ * const permissions = await authClient.role.getPermissions("role-123");
2323
+ * ```
2324
+ */
2325
+ getPermissions(roleId: string): Promise<Array<{
2326
+ id: string;
2327
+ name: string;
2328
+ code: string;
2329
+ description?: string;
2330
+ }>>;
2331
+ /**
2332
+ * Assign permissions to role
2333
+ *
2334
+ * @description มอบหมายสิทธิ์ให้บทบาท
2335
+ *
2336
+ * @example
2337
+ * ```typescript
2338
+ * await authClient.role.assignPermissions("role-123", ["perm-001", "perm-002"]);
2339
+ * ```
2340
+ */
2341
+ assignPermissions(roleId: string, permissionIds: string[]): Promise<boolean>;
2342
+ /**
2343
+ * Unassign permissions from role
2344
+ *
2345
+ * @description ยกเลิกสิทธิ์จากบทบาท
2346
+ *
2347
+ * @example
2348
+ * ```typescript
2349
+ * await authClient.role.unassignPermissions("role-123", ["perm-001"]);
2350
+ * ```
2351
+ */
2352
+ unassignPermissions(roleId: string, permissionIds: string[]): Promise<boolean>;
2353
+ }
2354
+ export { RoleAPI }
2355
+ export { RoleAPI as RoleAPI_alias_1 }
2356
+ export { RoleAPI as RoleAPI_alias_2 }
2357
+
2358
+ /**
2359
+ * Role Clear Response - ผลลัพธ์จากการลบ roles ตาม application_id
2360
+ * ใช้ application_id จาก RequestContext (API key/context)
2361
+ */
2362
+ declare interface RoleClearResponse {
2363
+ roles_deleted: number;
2364
+ role_permissions_deleted: number;
2365
+ user_role_assignments_deleted: number;
2366
+ }
2367
+ export { RoleClearResponse }
2368
+ export { RoleClearResponse as RoleClearResponse_alias_1 }
2369
+ export { RoleClearResponse as RoleClearResponse_alias_2 }
2370
+
2371
+ /**
2372
+ * Role Search Advanced Filters
2373
+ */
2374
+ declare interface RoleSearchAdvancedFilters {
2375
+ status?: string;
2376
+ is_active?: boolean;
2377
+ is_system?: boolean;
2378
+ }
2379
+ export { RoleSearchAdvancedFilters }
2380
+ export { RoleSearchAdvancedFilters as RoleSearchAdvancedFilters_alias_1 }
2381
+ export { RoleSearchAdvancedFilters as RoleSearchAdvancedFilters_alias_2 }
2382
+
2383
+ /**
2384
+ * Role Search Params - ข้อมูลสำหรับค้นหาบทบาท
2385
+ */
2386
+ declare interface RoleSearchParams {
2387
+ search?: string;
2388
+ page?: number;
2389
+ limit?: number;
2390
+ sort_by?: string;
2391
+ sort_order?: 'asc' | 'desc';
2392
+ advanced?: RoleSearchAdvancedFilters;
2393
+ }
2394
+ export { RoleSearchParams }
2395
+ export { RoleSearchParams as RoleSearchParams_alias_1 }
2396
+ export { RoleSearchParams as RoleSearchParams_alias_2 }
2397
+
2398
+ /**
2399
+ * Security JWT Configuration (GET /security/jwt - reads from session_management)
2400
+ * refreshThresholdMinutes, automaticRefreshEnabled: ระบุผ่าน AuthSdkConfig.advanced ตอนสร้าง client
2401
+ */
2402
+ declare interface SecurityJwtConfig {
2403
+ access_token_expiry_minutes: number;
2404
+ refresh_token_expiry_days: number;
2405
+ jwt_last_rotated_at?: string;
2406
+ }
2407
+ export { SecurityJwtConfig }
2408
+ export { SecurityJwtConfig as SecurityJwtConfig_alias_1 }
2409
+ export { SecurityJwtConfig as SecurityJwtConfig_alias_2 }
2410
+
2411
+ /**
2412
+ * Send Email API Request DTO (SDK)
2413
+ *
2414
+ * @description DTO สำหรับส่ง email ผ่าน SDK สำหรับ external applications
2415
+ * รองรับทั้ง Template Mode และ Raw HTML Mode
2416
+ *
2417
+ * === Template Mode ===
2418
+ * - template_code (required) - Template code จาก database
2419
+ * - template_data (optional) - ข้อมูลสำหรับ render template
2420
+ * - subject (optional) - Override subject จาก template
2421
+ * - language (optional) - Template language (default: 'th')
2422
+ *
2423
+ * === Raw HTML Mode ===
2424
+ * - html_body (required) - HTML content โดยตรง
2425
+ * - subject (required) - Email subject
2426
+ * - text_body (optional) - Plain text version (auto-generated ถ้าไม่ระบุ)
2427
+ *
2428
+ * === Recipients ===
2429
+ * - recipient_email (required ถ้าไม่มี recipient_id) - Email address
2430
+ * - recipient_id (required ถ้าไม่มี recipient_email) - User ID (ส่งผ่าน notification system)
2431
+ * - recipient_name (optional) - Display name
2432
+ * - cc (optional) - CC recipients (string หรือ array)
2433
+ * - bcc (optional) - BCC recipients (string หรือ array)
2434
+ *
2435
+ * === Attachments ===
2436
+ * - attachments (optional) - Array ของไฟล์แนบ
2437
+ *
2438
+ * === Validation ===
2439
+ * - ต้องมี template_code หรือ html_body อย่างใดอย่างหนึ่ง (mutual exclusivity)
2440
+ * - ถ้ามี template_code: subject เป็น optional (ใช้จาก template)
2441
+ * - ถ้ามี html_body: subject เป็น required
2442
+ * - ต้องมี recipient_email หรือ recipient_id อย่างใดอย่างหนึ่ง
2443
+ *
2444
+ * @example Template Mode
2445
+ * ```json
2446
+ * {
2447
+ * "template_code": "welcome_email",
2448
+ * "template_data": {
2449
+ * "userName": "สมชาย ใจดี",
2450
+ * "activationLink": "https://app.com/activate?token=xxx"
2451
+ * },
2452
+ * "recipient_email": "user@example.com",
2453
+ * "recipient_name": "สมชาย ใจดี",
2454
+ * "language": "th",
2455
+ * "cc": ["manager@example.com"],
2456
+ * "attachments": [
2457
+ * {
2458
+ * "filename": "welcome.pdf",
2459
+ * "path": "/uploads/welcome.pdf"
2460
+ * }
2461
+ * ]
2462
+ * }
2463
+ * ```
2464
+ *
2465
+ * @example Raw HTML Mode
2466
+ * ```json
2467
+ * {
2468
+ * "html_body": "<h1>ยินดีต้อนรับ</h1><p>ขอบคุณที่สมัครสมาชิก</p>",
2469
+ * "subject": "ยินดีต้อนรับสู่ระบบ",
2470
+ * "recipient_email": "user@example.com",
2471
+ * "text_body": "ยินดีต้อนรับ ขอบคุณที่สมัครสมาชิก",
2472
+ * "cc": ["manager@example.com"],
2473
+ * "bcc": ["archive@example.com"]
2474
+ * }
2475
+ * ```
2476
+ */
2477
+ declare interface SendEmailApiRequestDto {
2478
+ // === Template Mode (mutual exclusive with html_body) ===
2479
+ /**
2480
+ * Template code จาก database (required สำหรับ Template Mode)
2481
+ * @example "welcome_email"
2482
+ */
2483
+ template_code?: string;
2484
+
2485
+ /**
2486
+ * Template data สำหรับ render template (optional)
2487
+ * @example { "userName": "John", "activationLink": "https://..." }
2488
+ */
2489
+ template_data?: Record<string, any>;
2490
+
2491
+ /**
2492
+ * Template language (optional, default: 'th')
2493
+ * @example "th" | "en"
2494
+ */
2495
+ language?: 'th' | 'en';
2496
+
2497
+ /**
2498
+ * Override subject จาก template (optional)
2499
+ * ใช้เฉพาะเมื่อต้องการ override subject ที่กำหนดไว้ใน template
2500
+ */
2501
+ subject?: string;
2502
+
2503
+ // === Raw HTML Mode (mutual exclusive with template_code) ===
2504
+ /**
2505
+ * HTML content โดยตรง (required สำหรับ Raw HTML Mode)
2506
+ * @example "<h1>Hello</h1><p>World</p>"
2507
+ */
2508
+ html_body?: string;
2509
+
2510
+ /**
2511
+ * Plain text version (optional)
2512
+ * Auto-generated จาก html_body ถ้าไม่ระบุ
2513
+ */
2514
+ text_body?: string;
2515
+
2516
+ // === Recipients (ต้องมีอย่างใดอย่างหนึ่ง) ===
2517
+ /**
2518
+ * Email address ของผู้รับ (required ถ้าไม่มี recipient_id)
2519
+ * @example "user@example.com"
2520
+ */
2521
+ recipient_email?: string;
2522
+
2523
+ /**
2524
+ * User ID ของผู้รับ (required ถ้าไม่มี recipient_email)
2525
+ * จะส่งผ่าน notification system และสร้าง notification record
2526
+ * @example "user-123e4567-e89b-12d3-a456-426614174000"
2527
+ */
2528
+ recipient_id?: string;
2529
+
2530
+ /**
2531
+ * Display name ของผู้รับ (optional)
2532
+ * @example "สมชาย ใจดี"
2533
+ */
2534
+ recipient_name?: string;
2535
+
2536
+ // === Email Options ===
2537
+ /**
2538
+ * CC recipients (optional)
2539
+ * รองรับทั้ง string (single) และ array (multiple)
2540
+ * @example "manager@example.com" หรือ ["manager@example.com", "team@example.com"]
2541
+ */
2542
+ cc?: string | string[];
2543
+
2544
+ /**
2545
+ * BCC recipients (optional)
2546
+ * รองรับทั้ง string (single) และ array (multiple)
2547
+ * @example "archive@example.com" หรือ ["archive@example.com", "backup@example.com"]
2548
+ */
2549
+ bcc?: string | string[];
2550
+
2551
+ /**
2552
+ * Attachments (optional)
2553
+ * Array ของไฟล์แนบ
2554
+ *
2555
+ * ✅ **ใช้ URL (`href`) เท่านั้น** - Simple และ consistent
2556
+ *
2557
+ * **การใช้งาน:**
2558
+ * 1. External applications: Upload ไฟล์ผ่าน File API (`/files/upload`) แล้วได้ URL กลับมา
2559
+ * 2. Internal applications: ใช้ URL จาก storage service หรือ `/files/:id/content`
2560
+ * 3. Cloud storage: ใช้ URL จาก Azure Blob Storage, AWS S3, Google Cloud Storage, etc.
2561
+ *
2562
+ * @example
2563
+ * ```json
2564
+ * [
2565
+ * {
2566
+ * "filename": "report.pdf",
2567
+ * "href": "https://api.example.com/files/123e4567-e89b-12d3-a456-426614174000/content"
2568
+ * },
2569
+ * {
2570
+ * "filename": "document.pdf",
2571
+ * "href": "https://storage.azure.com/container/document.pdf"
2572
+ * }
2573
+ * ]
2574
+ * ```
2575
+ */
2576
+ attachments?: Array<{
2577
+ filename: string;
2578
+ href: string; // URL ของไฟล์ (required) - จาก File API, cloud storage, หรือ public URL
2579
+ content_type?: string; // MIME type (optional, auto-detect จาก filename หรือ URL)
2580
+ }>;
2581
+
2582
+ /**
2583
+ * Priority (optional, default: 'normal')
2584
+ * @example "low" | "normal" | "high" | "urgent"
2585
+ */
2586
+ priority?: 'low' | 'normal' | 'high' | 'urgent';
2587
+
2588
+ /**
2589
+ * Scheduled send time (optional)
2590
+ * @example "2024-01-20T10:00:00Z"
2591
+ */
2592
+ scheduled_at?: Date | string;
2593
+
2594
+ /**
2595
+ * Source identifier (optional)
2596
+ * สำหรับ tracking แหล่งที่มาของ email
2597
+ * @example "user_registration" | "order_confirmation"
2598
+ */
2599
+ source?: string;
2600
+
2601
+ /**
2602
+ * Related entity ID (optional)
2603
+ * สำหรับเชื่อมโยงกับ entity อื่น
2604
+ */
2605
+ related_entity_id?: string;
2606
+
2607
+ /**
2608
+ * Related entity type (optional)
2609
+ * @example "user" | "order" | "invoice"
2610
+ */
2611
+ related_entity_type?: string;
2612
+ }
2613
+ export { SendEmailApiRequestDto }
2614
+ export { SendEmailApiRequestDto as SendEmailApiRequestDto_alias_1 }
2615
+ export { SendEmailApiRequestDto as SendEmailApiRequestDto_alias_2 }
2616
+
2617
+ /**
2618
+ * Send Email API Response - ข้อมูลตอบกลับเมื่อส่ง email สำเร็จ
2619
+ */
2620
+ declare interface SendEmailApiResponseDto {
2621
+ /**
2622
+ * Email queue ID (UUID)
2623
+ */
2624
+ email_id: string;
2625
+ /**
2626
+ * Email status
2627
+ * - 'queued': ถูกเพิ่มเข้า queue แล้ว (รอส่ง)
2628
+ * - 'sent': ส่งสำเร็จแล้ว
2629
+ * - 'failed': ส่งล้มเหลว
2630
+ */
2631
+ status: 'queued' | 'sent' | 'failed';
2632
+ /**
2633
+ * Recipient email address
2634
+ */
2635
+ recipient_email: string;
2636
+ /**
2637
+ * Email subject
2638
+ */
2639
+ subject: string;
2640
+ /**
2641
+ * Timestamp when email was queued
2642
+ */
2643
+ queued_at: Date | string;
2644
+ /**
2645
+ * Message ID from SMTP server (optional)
2646
+ * มีเฉพาะเมื่อส่งทันที (ไม่ผ่าน queue)
2647
+ */
2648
+ message_id?: string;
2649
+ }
2650
+ export { SendEmailApiResponseDto }
2651
+ export { SendEmailApiResponseDto as SendEmailApiResponseDto_alias_1 }
2652
+ export { SendEmailApiResponseDto as SendEmailApiResponseDto_alias_2 }
2653
+
2654
+ /**
2655
+ * Type aliases for cleaner API usage
2656
+ * @alias SendEmailRequest = SendEmailApiRequestDto
2657
+ * @alias SendEmailResponse = SendEmailApiResponseDto
2658
+ */
2659
+ declare type SendEmailRequest = SendEmailApiRequestDto;
2660
+ export { SendEmailRequest }
2661
+ export { SendEmailRequest as SendEmailRequest_alias_1 }
2662
+ export { SendEmailRequest as SendEmailRequest_alias_2 }
2663
+
2664
+ declare type SendEmailResponse = SendEmailApiResponseDto;
2665
+ export { SendEmailResponse }
2666
+ export { SendEmailResponse as SendEmailResponse_alias_1 }
2667
+ export { SendEmailResponse as SendEmailResponse_alias_2 }
2668
+
2669
+ declare interface SendImageRequest {
2670
+ userId: string;
2671
+ originalContentUrl: string;
2672
+ previewImageUrl: string;
2673
+ }
2674
+ export { SendImageRequest }
2675
+ export { SendImageRequest as SendImageRequest_alias_1 }
2676
+ export { SendImageRequest as SendImageRequest_alias_2 }
2677
+
2678
+ declare interface SendMessagesRequest {
2679
+ userId: string;
2680
+ messages: LineMessagePayload[];
2681
+ }
2682
+ export { SendMessagesRequest }
2683
+ export { SendMessagesRequest as SendMessagesRequest_alias_1 }
2684
+ export { SendMessagesRequest as SendMessagesRequest_alias_2 }
2685
+
2686
+ declare interface SendNotificationRequest {
2687
+ userId: string;
2688
+ title: string;
2689
+ message: string;
2690
+ type?: 'info' | 'success' | 'warning' | 'error';
2691
+ action_url?: string;
2692
+ priority?: 'low' | 'normal' | 'high';
2693
+ }
2694
+ export { SendNotificationRequest }
2695
+ export { SendNotificationRequest as SendNotificationRequest_alias_1 }
2696
+ export { SendNotificationRequest as SendNotificationRequest_alias_2 }
2697
+
2698
+ /**
2699
+ * Send OTP Request
2700
+ */
2701
+ declare interface SendOTPRequest {
2702
+ method: 'sms' | 'email';
2703
+ recipient: string;
2704
+ context?: string;
2705
+ metadata?: string;
2706
+ }
2707
+ export { SendOTPRequest }
2708
+ export { SendOTPRequest as SendOTPRequest_alias_1 }
2709
+ export { SendOTPRequest as SendOTPRequest_alias_2 }
2710
+
2711
+ /**
2712
+ * Send OTP Response
2713
+ */
2714
+ declare interface SendOTPResponse {
2715
+ otp_id: string;
2716
+ ref_code: string;
2717
+ expires_at: Date;
2718
+ masked_recipient: string;
2719
+ }
2720
+ export { SendOTPResponse }
2721
+ export { SendOTPResponse as SendOTPResponse_alias_1 }
2722
+ export { SendOTPResponse as SendOTPResponse_alias_2 }
2723
+
2724
+ declare interface SendStickerRequest {
2725
+ userId: string;
2726
+ packageId: string;
2727
+ stickerId: string;
2728
+ }
2729
+ export { SendStickerRequest }
2730
+ export { SendStickerRequest as SendStickerRequest_alias_1 }
2731
+ export { SendStickerRequest as SendStickerRequest_alias_2 }
2732
+
2733
+ declare interface SendTextMessageRequest {
2734
+ userId: string;
2735
+ message: string;
2736
+ }
2737
+ export { SendTextMessageRequest }
2738
+ export { SendTextMessageRequest as SendTextMessageRequest_alias_1 }
2739
+ export { SendTextMessageRequest as SendTextMessageRequest_alias_2 }
2740
+
2741
+ /**
2742
+ * Session Management Configuration (unified with JWT)
2743
+ * Configuration for session timeout, expiration, and token settings
2744
+ */
2745
+ declare interface SessionManagementConfig {
2746
+ inactivity: {
2747
+ enabled: boolean;
2748
+ timeout_minutes: number;
2749
+ warning_minutes: number;
2750
+ };
2751
+ lifetime: {
2752
+ enabled: boolean;
2753
+ max_lifetime_days: number;
2754
+ };
2755
+ concurrent: {
2756
+ enabled: boolean;
2757
+ max_sessions: number;
2758
+ };
2759
+ notify_on_new_device?: boolean;
2760
+ /** JWT fields (unified from session_management) */
2761
+ jwt_last_rotated_at?: string;
2762
+ access_token_expiry_minutes?: number;
2763
+ refresh_token_expiry_days?: number;
2764
+ }
2765
+ export { SessionManagementConfig }
2766
+ export { SessionManagementConfig as SessionManagementConfig_alias_1 }
2767
+ export { SessionManagementConfig as SessionManagementConfig_alias_2 }
2768
+
2769
+ /**
2770
+ * System Config Types - SDK Friendly
2771
+ *
2772
+ * Clean, client-focused type names without DTO suffixes
2773
+ */
2774
+ /**
2775
+ * System Configuration
2776
+ * A single configuration entry
2777
+ * Matches SystemConfigResponseDto from @win-portal/shared
2778
+ */
2779
+ declare interface SystemConfig {
2780
+ id: string;
2781
+ category: string;
2782
+ key: string;
2783
+ value: any;
2784
+ description?: string;
2785
+ data_type?: string;
2786
+ is_secret: boolean;
2787
+ is_read_only: boolean;
2788
+ is_active: boolean;
2789
+ version?: string;
2790
+ metadata?: {
2791
+ feature?: string;
2792
+ last_updated_by?: string;
2793
+ migration_source?: string;
2794
+ validation?: {
2795
+ required?: boolean;
2796
+ min?: number;
2797
+ max?: number;
2798
+ enum?: any[];
2799
+ pattern?: string;
2800
+ };
2801
+ };
2802
+ created_at: string;
2803
+ updated_at: string;
2804
+ status: string;
2805
+ full_key?: string;
2806
+ }
2807
+ export { SystemConfig }
2808
+ export { SystemConfig as SystemConfig_alias_1 }
2809
+ export { SystemConfig as SystemConfig_alias_2 }
2810
+
2811
+ /**
2812
+ * System Config API
2813
+ * Methods for retrieving system configurations
2814
+ * Based on: apps/api/src/modules/shared/core/controllers/system-config.controller.ts
2815
+ */
2816
+ declare class SystemConfigAPI {
2817
+ private readonly axios;
2818
+ constructor(axios: AxiosInstance);
2819
+ /**
2820
+ * GET /system-configs/categories/:category
2821
+ * ดึง configs ตาม category - ส่ง object ที่รวมทุก key เป็น { key1: value1, key2: value2 }
2822
+ */
2823
+ private getByCategory;
2824
+ /**
2825
+ * GET /system-configs/categories/:category/:key
2826
+ * ดึง config value ตรงๆ (API returns config.value directly, NOT the full SystemConfig row)
2827
+ */
2828
+ private getByCategoryAndKey;
2829
+ /**
2830
+ * Get config by category (returns all keys), or by category+key (returns value directly)
2831
+ */
2832
+ get(category: string): Promise<SystemConfigByCategory>;
2833
+ get<T = any>(category: string, key: string): Promise<T>;
2834
+ /**
2835
+ * GET /system-configs/categories/security/session_management
2836
+ * ดึง Session Management configuration (convenience method)
2837
+ */
2838
+ getSessionManagement(): Promise<SessionManagementConfig>;
2839
+ /**
2840
+ * GET /system-configs/categories/security/jwt
2841
+ * ดึง Security JWT configuration (convenience method)
2842
+ */
2843
+ getSecurityJwt(): Promise<SecurityJwtConfig>;
2844
+ }
2845
+ export { SystemConfigAPI }
2846
+ export { SystemConfigAPI as SystemConfigAPI_alias_1 }
2847
+ export { SystemConfigAPI as SystemConfigAPI_alias_2 }
2848
+
2849
+ /**
2850
+ * System Config by Category
2851
+ * Returns an object with key-value pairs for a category
2852
+ */
2853
+ declare type SystemConfigByCategory = Record<string, any>;
2854
+ export { SystemConfigByCategory }
2855
+ export { SystemConfigByCategory as SystemConfigByCategory_alias_1 }
2856
+ export { SystemConfigByCategory as SystemConfigByCategory_alias_2 }
2857
+
2858
+ /**
2859
+ * Task Action Request
2860
+ */
2861
+ declare interface TaskActionRequest {
2862
+ action_key: string;
2863
+ comments?: string;
2864
+ delegate_to_user_id?: string;
2865
+ escalate_to_user_id?: string;
2866
+ return_to_node_id?: string;
2867
+ reason?: string;
2868
+ [key: string]: any;
2869
+ }
2870
+ export { TaskActionRequest }
2871
+ export { TaskActionRequest as TaskActionRequest_alias_1 }
2872
+ export { TaskActionRequest as TaskActionRequest_alias_2 }
2873
+
2874
+ /**
2875
+ * Todo Response
2876
+ *
2877
+ * @description Complete todo data returned from API
2878
+ * Matches TodoResponseDto from @win-portal/shared
2879
+ *
2880
+ * @properties
2881
+ * - id: รหัส todo (required) UUID ของ todo
2882
+ * - title: หัวข้องาน (required) ชื่อหรือหัวข้อของงานที่ต้องทำ
2883
+ * - description: รายละเอียดงาน (optional) คำอธิบายเพิ่มเติมของงาน
2884
+ * - due_date: วันครบกำหนด (optional) วันที่ต้องเสร็จงาน
2885
+ * - priority: ระดับความสำคัญ (required) เช่น low, normal, high
2886
+ * - is_completed: สถานะเสร็จ (required) true = เสร็จแล้ว, false = ยังไม่เสร็จ
2887
+ * - completed_at: วันที่เสร็จ (optional) timestamp เมื่อ mark เป็นเสร็จ
2888
+ * - category: หมวดหมู่ (optional) เช่น "work", "personal", "shopping"
2889
+ * - labels: ป้ายกำกับ (optional) tags สำหรับการค้นหาและจัดกลุ่ม
2890
+ * - link_url: ลิงก์อ้างอิง (optional) URL ที่เกี่ยวข้องกับงาน
2891
+ * - is_send_notification: ส่งการแจ้งเตือน (required) การตั้งค่า notification
2892
+ * - user_id: รหัสผู้ใช้ (required) เป็นของ user คนนี้
2893
+ * - application_id: รหัสแอปพลิเคชัน (optional) แอปพลิเคชันที่สร้าง todo นี้
2894
+ * - created_at: วันที่สร้าง (required) timestamp เมื่อสร้าง todo
2895
+ * - updated_at: วันที่แก้ไข (required) timestamp เมื่อแก้ไขล่าสุด
2896
+ * - status: สถานะ entity (required) จาก IBaseEntity
2897
+ * - is_overdue: เกินกำหนด (computed) true = เกินวันครบกำหนดแล้ว
2898
+ * - days_until_due: จำนวนวันจนครบกำหนด (computed) จำนวนวันที่เหลือ
2899
+ * - application: ข้อมูลแอปพลิเคชัน (optional) ข้อมูลแอปพลิเคชันที่เกี่ยวข้อง
2900
+ * - sub_tasks: รายการ sub-tasks (optional) รายการ sub-tasks ของ todo นี้
2901
+ * - subtasks_count: จำนวน sub-tasks (optional) จำนวน sub-tasks ทั้งหมด
2902
+ * - completed_subtasks_count: จำนวน sub-tasks ที่เสร็จแล้ว (optional)
2903
+ * - assigned_to: ข้อมูลผู้รับผิดชอบ (optional) ข้อมูล user ที่รับผิดชอบ
2904
+ * - assigned_by: ข้อมูลผู้มอบหมาย (optional) ข้อมูล user ที่มอบหมาย
2905
+ *
2906
+ * @example
2907
+ * ```typescript
2908
+ * const todo: Todo = {
2909
+ * id: "todo123e4567-e89b-12d3-a456-426614174000",
2910
+ * title: "ซื้อของใช้ในบ้าน",
2911
+ * description: "ซื้อน้ำยาล้างจาน, กระดาษทิชชู่, แชมพู",
2912
+ * due_date: "2024-01-20T17:00:00Z",
2913
+ * priority: "normal",
2914
+ * is_completed: false,
2915
+ * category: "shopping",
2916
+ * labels: ["บ้าน", "จำเป็น"],
2917
+ * link_url: "https://www.bigc.co.th/shopping-list",
2918
+ * is_send_notification: true,
2919
+ * user_id: "user123e4567-e89b-12d3-a456-426614174000",
2920
+ * application_id: "app123e4567-e89b-12d3-a456-426614174000",
2921
+ * created_at: "2024-01-15T10:00:00Z",
2922
+ * updated_at: "2024-01-15T10:00:00Z",
2923
+ * status: "active",
2924
+ * is_overdue: false,
2925
+ * days_until_due: 5
2926
+ * };
2927
+ * ```
2928
+ */
2929
+ declare interface Todo {
2930
+ id: string;
2931
+ created_at: string;
2932
+ updated_at: string;
2933
+ status: string;
2934
+ title: string;
2935
+ description?: string;
2936
+ due_date?: string;
2937
+ priority: TodoPriority | string;
2938
+ is_completed: boolean;
2939
+ completed_at?: string;
2940
+ category?: string;
2941
+ labels?: string[];
2942
+ link_url?: string;
2943
+ is_send_notification: boolean;
2944
+ user_id: string;
2945
+ application_id?: string;
2946
+ parent_id?: string;
2947
+ order?: number;
2948
+ level?: number;
2949
+ assigned_to_id?: string;
2950
+ assigned_by_id?: string;
2951
+ assigned_at?: string;
2952
+ is_overdue?: boolean;
2953
+ days_until_due?: number;
2954
+ application?: {
2955
+ id: string;
2956
+ name: string;
2957
+ code: string;
2958
+ };
2959
+ sub_tasks?: Todo[];
2960
+ subtasks_count?: number;
2961
+ completed_subtasks_count?: number;
2962
+ assigned_to?: {
2963
+ id: string;
2964
+ first_name: string;
2965
+ last_name: string;
2966
+ email: string;
2967
+ };
2968
+ assigned_by?: {
2969
+ id: string;
2970
+ first_name: string;
2971
+ last_name: string;
2972
+ email: string;
2973
+ };
2974
+ }
2975
+ export { Todo }
2976
+ export { Todo as Todo_alias_1 }
2977
+ export { Todo as Todo_alias_2 }
2978
+
2979
+ declare class TodoAPI {
2980
+ private readonly axios;
2981
+ constructor(axios: AxiosInstance);
2982
+ /**
2983
+ * Create a new todo
2984
+ *
2985
+ * @example
2986
+ * ```typescript
2987
+ * const todo = await authClient.todo.create({
2988
+ * title: "ซื้อของใช้ในบ้าน",
2989
+ * priority: TodoPriority.NORMAL,
2990
+ * user_id: "user123e4567-e89b-12d3-a456-426614174000",
2991
+ * description: "ซื้อน้ำยาล้างจาน, กระดาษทิชชู่, แชมพู",
2992
+ * due_date: new Date("2024-01-20T17:00:00Z"),
2993
+ * category: "shopping",
2994
+ * labels: ["บ้าน", "จำเป็น"],
2995
+ * is_send_notification: true
2996
+ * });
2997
+ * ```
2998
+ */
2999
+ create(todoData: CreateTodoRequest): Promise<Todo>;
3000
+ }
3001
+ export { TodoAPI }
3002
+ export { TodoAPI as TodoAPI_alias_1 }
3003
+ export { TodoAPI as TodoAPI_alias_2 }
3004
+
3005
+ /**
3006
+ * Todo Priority Enum
3007
+ *
3008
+ * @description ระดับความสำคัญของงานใน todo list
3009
+ */
3010
+ declare enum TodoPriority {
3011
+ LOW = 'low',
3012
+ NORMAL = 'normal',
3013
+ HIGH = 'high',
3014
+ }
3015
+ export { TodoPriority }
3016
+ export { TodoPriority as TodoPriority_alias_1 }
3017
+ export { TodoPriority as TodoPriority_alias_2 }
3018
+
3019
+ /**
3020
+ * Update Organization Request
3021
+ */
3022
+ declare interface UpdateOrganizationRequest {
3023
+ name?: string;
3024
+ code?: string;
3025
+ parent_id?: string;
3026
+ description?: string;
3027
+ logo_file_id?: string;
3028
+ report_to_position_id?: string;
3029
+ is_active?: boolean;
3030
+ }
3031
+ export { UpdateOrganizationRequest }
3032
+ export { UpdateOrganizationRequest as UpdateOrganizationRequest_alias_1 }
3033
+ export { UpdateOrganizationRequest as UpdateOrganizationRequest_alias_2 }
3034
+
3035
+ /**
3036
+ * Update Permission Category Request
3037
+ */
3038
+ declare interface UpdatePermissionCategoryRequest {
3039
+ name?: string;
3040
+ key?: string;
3041
+ description?: string;
3042
+ resource?: string;
3043
+ parent_id?: string;
3044
+ permissions?: Omit<CreatePermissionRequest, 'category_id'>[];
3045
+ }
3046
+ export { UpdatePermissionCategoryRequest }
3047
+ export { UpdatePermissionCategoryRequest as UpdatePermissionCategoryRequest_alias_1 }
3048
+ export { UpdatePermissionCategoryRequest as UpdatePermissionCategoryRequest_alias_2 }
3049
+
3050
+ /**
3051
+ * Update Permission Request
3052
+ */
3053
+ declare interface UpdatePermissionRequest {
3054
+ name?: string;
3055
+ key?: string;
3056
+ description?: string;
3057
+ }
3058
+ export { UpdatePermissionRequest }
3059
+ export { UpdatePermissionRequest as UpdatePermissionRequest_alias_1 }
3060
+ export { UpdatePermissionRequest as UpdatePermissionRequest_alias_2 }
3061
+
3062
+ /**
3063
+ * Update Role Request - ข้อมูลสำหรับอัพเดทบทบาท
3064
+ */
3065
+ declare interface UpdateRoleRequest {
3066
+ name?: string;
3067
+ code?: string;
3068
+ description?: string;
3069
+ }
3070
+ export { UpdateRoleRequest }
3071
+ export { UpdateRoleRequest as UpdateRoleRequest_alias_1 }
3072
+ export { UpdateRoleRequest as UpdateRoleRequest_alias_2 }
3073
+
3074
+ /**
3075
+ * Update User Request - ข้อมูลสำหรับอัปเดตผู้ใช้
3076
+ * Matches UpdateUserRequestDto from @win-portal/shared
3077
+ */
3078
+ declare interface UpdateUserRequest {
3079
+ first_name?: string;
3080
+ last_name?: string;
3081
+ first_name_en?: string;
3082
+ last_name_en?: string;
3083
+ username?: string;
3084
+ code?: string;
3085
+ phone_number?: string;
3086
+ avatar_file_id?: string;
3087
+ signature_file_id?: string;
3088
+ role_ids?: string[];
3089
+ metadata?: Record<string, any>;
3090
+ preferences?: {
3091
+ language?: string;
3092
+ timezone?: string;
3093
+ notifications?: boolean;
3094
+ theme?: string;
3095
+ [key: string]: any;
3096
+ };
3097
+ }
3098
+ export { UpdateUserRequest }
3099
+ export { UpdateUserRequest as UpdateUserRequest_alias_1 }
3100
+ export { UpdateUserRequest as UpdateUserRequest_alias_2 }
3101
+
3102
+ /**
3103
+ * Update Workflow Instance Request
3104
+ */
3105
+ declare interface UpdateWorkflowInstanceRequest {
3106
+ document_title?: string;
3107
+ document_url?: string;
3108
+ priority?: 'low' | 'normal' | 'high' | 'urgent';
3109
+ form_data?: Record<string, any>;
3110
+ context_variables?: Record<string, any>;
3111
+ }
3112
+ export { UpdateWorkflowInstanceRequest }
3113
+ export { UpdateWorkflowInstanceRequest as UpdateWorkflowInstanceRequest_alias_1 }
3114
+ export { UpdateWorkflowInstanceRequest as UpdateWorkflowInstanceRequest_alias_2 }
3115
+
3116
+ /**
3117
+ * User Types for Auth SDK
3118
+ *
3119
+ * @description Types สำหรับ user CRUD operations ใน SDK
3120
+ */
3121
+ /**
3122
+ * User - ข้อมูลผู้ใช้พื้นฐาน
3123
+ * Matches UserResponseDto from @win-portal/shared
3124
+ */
3125
+ declare interface User {
3126
+ id: string;
3127
+ code?: string;
3128
+ email: string;
3129
+ username?: string;
3130
+ first_name: string;
3131
+ last_name: string;
3132
+ first_name_en?: string;
3133
+ last_name_en?: string;
3134
+ avatar_file_id?: string;
3135
+ avatar_url?: string;
3136
+ signature_file_id?: string;
3137
+ signature_url?: string;
3138
+ phone_number?: string;
3139
+ status: string;
3140
+ last_login_at?: Date | string;
3141
+ login_attempts: number;
3142
+ locked_until?: Date | string;
3143
+ must_change_password: boolean;
3144
+ is_system: boolean;
3145
+ created_at: Date | string;
3146
+ updated_at: Date | string;
3147
+ full_name?: string;
3148
+ permissions: string[];
3149
+ roles: Array<{
3150
+ id: string;
3151
+ name: string;
3152
+ code: string;
3153
+ description?: string;
3154
+ }>;
3155
+ positions?: Array<{
3156
+ id: string;
3157
+ name: string;
3158
+ code: string;
3159
+ type?: string;
3160
+ is_primary: boolean;
3161
+ }>;
3162
+ primary_position?: {
3163
+ id: string;
3164
+ name: string;
3165
+ code: string;
3166
+ type?: string;
3167
+ } | null;
3168
+ primary_department?: {
3169
+ id: string;
3170
+ name: string;
3171
+ code: string;
3172
+ type?: string;
3173
+ } | null;
3174
+ metadata?: Record<string, any>;
3175
+ }
3176
+ export { User }
3177
+ export { User as User_alias_1 }
3178
+ export { User as User_alias_2 }
3179
+
3180
+ declare class UserAPI {
3181
+ private readonly axios;
3182
+ constructor(axios: AxiosInstance);
3183
+ /**
3184
+ * Search users with pagination and filters
3185
+ *
3186
+ * @example
3187
+ * ```typescript
3188
+ * const result = await authClient.user.search({
3189
+ * search: "สมชาย",
3190
+ * page: 1,
3191
+ * limit: 20,
3192
+ * sort_by: "created_at",
3193
+ * sort_order: "desc",
3194
+ * advanced: {
3195
+ * status: "active",
3196
+ * department_id: "dept-123"
3197
+ * }
3198
+ * });
3199
+ *
3200
+ * // Access paginated data
3201
+ * console.log(result.data); // User[]
3202
+ * console.log(result.pagination.total); // Total count
3203
+ * console.log(result.pagination.has_next); // Has next page
3204
+ * ```
3205
+ */
3206
+ search(params?: UserSearchParams): Promise<ApiPaginatedResponse<User>>;
3207
+ /**
3208
+ * Get user by ID
3209
+ *
3210
+ * @example
3211
+ * ```typescript
3212
+ * const user = await authClient.user.get("user-123");
3213
+ * ```
3214
+ */
3215
+ get(userId: string): Promise<User>;
3216
+ /**
3217
+ * Create a new user
3218
+ *
3219
+ * @description ถ้าไม่ระบุ password ระบบจะ auto generate และส่ง reset password link ไปทางอีเมล
3220
+ * ถ้าระบุ password ระบบจะใช้ password ที่ส่งมาและส่ง welcome email พร้อม login link
3221
+ *
3222
+ * @example
3223
+ * ```typescript
3224
+ * // กรณีที่มี password - ระบบจะส่ง welcome email พร้อม login link
3225
+ * const newUser = await authClient.user.create({
3226
+ * email: "user@example.com",
3227
+ * first_name: "สมชาย",
3228
+ * last_name: "ใจดี",
3229
+ * password: "SecurePassword123!",
3230
+ * code: "USR-2024-001",
3231
+ * role_ids: ["role-123", "role-456"] // Optional: assign roles immediately
3232
+ * });
3233
+ * ```
3234
+ *
3235
+ * @example
3236
+ * ```typescript
3237
+ * // กรณีที่ไม่มี password - ระบบจะ auto generate และส่ง welcome email พร้อม reset password link
3238
+ * const newUser = await authClient.user.create({
3239
+ * email: "user@example.com",
3240
+ * first_name: "สมชาย",
3241
+ * last_name: "ใจดี",
3242
+ * code: "USR-2024-002"
3243
+ * });
3244
+ * ```
3245
+ */
3246
+ create(userData: CreateUserRequest): Promise<User>;
3247
+ /**
3248
+ * Update user
3249
+ *
3250
+ * @example
3251
+ * ```typescript
3252
+ * const updatedUser = await authClient.user.update("user-123", {
3253
+ * first_name: "สมชาย",
3254
+ * last_name: "ใจดีมาก",
3255
+ * phone_number: "+66812345678",
3256
+ * role_ids: ["role-123", "role-456"] // Optional: replace all roles
3257
+ * });
3258
+ * ```
3259
+ */
3260
+ update(userId: string, userData: UpdateUserRequest): Promise<User>;
3261
+ /**
3262
+ * Delete user
3263
+ *
3264
+ * @example
3265
+ * ```typescript
3266
+ * await authClient.user.delete("user-123");
3267
+ * ```
3268
+ */
3269
+ delete(userId: string): Promise<void>;
3270
+ /**
3271
+ * Get user positions
3272
+ *
3273
+ * @description ดึงรายการตำแหน่งทั้งหมดของผู้ใช้
3274
+ *
3275
+ * @example
3276
+ * ```typescript
3277
+ * const positions = await authClient.user.getPositions("user-123");
3278
+ * const primaryPosition = positions.find(p => p.is_primary);
3279
+ * ```
3280
+ */
3281
+ getPositions(userId: string): Promise<User['positions']>;
3282
+ /**
3283
+ * Assign positions to user
3284
+ *
3285
+ * @description มอบหมายตำแหน่งให้ผู้ใช้ รองรับการมอบหมายหลายตำแหน่งพร้อมกัน
3286
+ *
3287
+ * @example
3288
+ * ```typescript
3289
+ * // Replace mode (default) - ทับตำแหน่งเดิมทั้งหมด
3290
+ * const result = await authClient.user.assignPositions("user-123", {
3291
+ * positions: [
3292
+ * { position_id: "pos-001", is_primary: true },
3293
+ * { position_id: "pos-002", is_primary: false }
3294
+ * ],
3295
+ * mode: "replace"
3296
+ * });
3297
+ *
3298
+ * // Add mode - เพิ่มตำแหน่งใหม่โดยไม่ลบของเดิม
3299
+ * const result = await authClient.user.assignPositions("user-123", {
3300
+ * positions: [
3301
+ * { position_id: "pos-003", is_primary: false }
3302
+ * ],
3303
+ * mode: "add"
3304
+ * });
3305
+ * ```
3306
+ */
3307
+ assignPositions(userId: string, data: AssignPositionsRequest): Promise<AssignmentResponse>;
3308
+ /**
3309
+ * Unassign positions from user
3310
+ *
3311
+ * @description ยกเลิกตำแหน่งจากผู้ใช้
3312
+ *
3313
+ * @example
3314
+ * ```typescript
3315
+ * const result = await authClient.user.unassignPositions("user-123", ["pos-001", "pos-002"]);
3316
+ * ```
3317
+ */
3318
+ unassignPositions(userId: string, positionIds: string[]): Promise<AssignmentResponse>;
3319
+ /**
3320
+ * Get user roles
3321
+ *
3322
+ * @description ดึงรายการบทบาททั้งหมดของผู้ใช้
3323
+ *
3324
+ * @example
3325
+ * ```typescript
3326
+ * const roles = await authClient.user.getRoles("user-123");
3327
+ * console.log(roles.map(r => r.name)); // ["Admin", "Manager"]
3328
+ * ```
3329
+ */
3330
+ getRoles(userId: string): Promise<Role[]>;
3331
+ /**
3332
+ * Assign roles to user
3333
+ *
3334
+ * @description มอบหมายบทบาทให้ผู้ใช้ (แทนที่บทบาทเดิมทั้งหมด)
3335
+ *
3336
+ * @example
3337
+ * ```typescript
3338
+ * const result = await authClient.user.assignRoles("user-123", ["role-001", "role-002"]);
3339
+ * ```
3340
+ */
3341
+ assignRoles(userId: string, roleIds: string[]): Promise<AssignmentResponse>;
3342
+ /**
3343
+ * Unassign roles from user
3344
+ *
3345
+ * @description ยกเลิกบทบาทจากผู้ใช้
3346
+ *
3347
+ * @example
3348
+ * ```typescript
3349
+ * const result = await authClient.user.unassignRoles("user-123", ["role-001"]);
3350
+ * ```
3351
+ */
3352
+ unassignRoles(userId: string, roleIds: string[]): Promise<AssignmentResponse>;
3353
+ /**
3354
+ * Sync users for external applications
3355
+ *
3356
+ * @description ดึงข้อมูลผู้ใช้แบบ paginated สำหรับ sync operations
3357
+ * ใช้สำหรับ external applications ที่ต้องการ sync user data
3358
+ * ต้องใช้ API Key authentication
3359
+ *
3360
+ * @example
3361
+ * ```typescript
3362
+ * // Sync all users (first page)
3363
+ * const result = await authClient.user.sync({
3364
+ * page: 1,
3365
+ * page_size: 100
3366
+ * });
3367
+ *
3368
+ * // Sync users updated after specific date
3369
+ * const updatedUsers = await authClient.user.sync({
3370
+ * page: 1,
3371
+ * page_size: 100,
3372
+ * updated_after: new Date('2024-01-01')
3373
+ * });
3374
+ *
3375
+ * // Access paginated data
3376
+ * console.log(result.data); // UserSyncResponse[]
3377
+ * console.log(result.pagination.total); // Total count
3378
+ * console.log(result.pagination.has_next); // Has next page
3379
+ * ```
3380
+ */
3381
+ sync(params?: UserSyncParams): Promise<ApiPaginatedResponse<UserSyncResponse>>;
3382
+ }
3383
+ export { UserAPI }
3384
+ export { UserAPI as UserAPI_alias_1 }
3385
+ export { UserAPI as UserAPI_alias_2 }
3386
+
3387
+ /**
3388
+ * User Position Assignment - ข้อมูลตำแหน่งสำหรับการมอบหมายให้ผู้ใช้
3389
+ *
3390
+ * Structurally identical to `@win-portal/shared` `UserPositionAssignmentDto`.
3391
+ * Kept local so api-extractor can inline the shape into the published dts
3392
+ * without retaining a reference to `@win-portal/shared`.
3393
+ */
3394
+ declare interface UserPositionAssignment {
3395
+ position_id: string;
3396
+ is_primary: boolean;
3397
+ }
3398
+ export { UserPositionAssignment }
3399
+ export { UserPositionAssignment as UserPositionAssignment_alias_1 }
3400
+ export { UserPositionAssignment as UserPositionAssignment_alias_2 }
3401
+
3402
+ /**
3403
+ * User Search Advanced Filters
3404
+ */
3405
+ declare interface UserSearchAdvancedFilters {
3406
+ status?: string;
3407
+ is_active?: boolean;
3408
+ is_locked?: boolean;
3409
+ department_id?: string;
3410
+ position_id?: string;
3411
+ role_id?: string;
3412
+ has_roles?: boolean;
3413
+ date_range?: {
3414
+ start: Date | string;
3415
+ end: Date | string;
3416
+ };
3417
+ has_logged_in?: boolean;
3418
+ last_login_range?: {
3419
+ start: Date | string;
3420
+ end: Date | string;
3421
+ };
3422
+ }
3423
+ export { UserSearchAdvancedFilters }
3424
+ export { UserSearchAdvancedFilters as UserSearchAdvancedFilters_alias_1 }
3425
+ export { UserSearchAdvancedFilters as UserSearchAdvancedFilters_alias_2 }
3426
+
3427
+ /**
3428
+ * User Search Params - ข้อมูลสำหรับค้นหาผู้ใช้
3429
+ */
3430
+ declare interface UserSearchParams {
3431
+ search?: string;
3432
+ page?: number;
3433
+ limit?: number;
3434
+ sort_by?: string;
3435
+ sort_order?: 'asc' | 'desc';
3436
+ advanced?: UserSearchAdvancedFilters;
3437
+ }
3438
+ export { UserSearchParams }
3439
+ export { UserSearchParams as UserSearchParams_alias_1 }
3440
+ export { UserSearchParams as UserSearchParams_alias_2 }
3441
+
3442
+ /**
3443
+ * User Summary - ข้อมูลผู้ใช้แบบย่อสำหรับ tree node
3444
+ */
3445
+ declare interface UserSummary {
3446
+ id: string;
3447
+ code?: string;
3448
+ email: string;
3449
+ fullname: string;
3450
+ first_name?: string;
3451
+ last_name?: string;
3452
+ username?: string;
3453
+ avatar_url?: string;
3454
+ status: string;
3455
+ positions?: Array<{
3456
+ id: string;
3457
+ name: string;
3458
+ code: string;
3459
+ type: string;
3460
+ is_primary: boolean;
3461
+ }>;
3462
+ }
3463
+ export { UserSummary }
3464
+ export { UserSummary as UserSummary_alias_1 }
3465
+ export { UserSummary as UserSummary_alias_2 }
3466
+
3467
+ /**
3468
+ * User Sync Params - ข้อมูลสำหรับ sync users
3469
+ */
3470
+ declare interface UserSyncParams {
3471
+ page?: number;
3472
+ page_size?: number;
3473
+ updated_after?: Date | string;
3474
+ }
3475
+ export { UserSyncParams }
3476
+ export { UserSyncParams as UserSyncParams_alias_1 }
3477
+ export { UserSyncParams as UserSyncParams_alias_2 }
3478
+
3479
+ /**
3480
+ * User Sync Response - ข้อมูลผู้ใช้สำหรับ sync operations
3481
+ * Matches UserSyncResponseDto from @win-portal/shared
3482
+ */
3483
+ declare interface UserSyncResponse {
3484
+ id: string;
3485
+ code: string;
3486
+ email: string;
3487
+ username: string;
3488
+ first_name: string;
3489
+ last_name: string;
3490
+ first_name_en: string;
3491
+ last_name_en: string;
3492
+ phone_number: string;
3493
+ avatar_url: string;
3494
+ signature_url: string;
3495
+ status: string;
3496
+ is_active: boolean;
3497
+ is_system: boolean;
3498
+ roles: Array<{
3499
+ id: string;
3500
+ name: string;
3501
+ code: string;
3502
+ }>;
3503
+ positions: Array<{
3504
+ id: string;
3505
+ title: string;
3506
+ code: string;
3507
+ department: {
3508
+ id: string;
3509
+ name: string;
3510
+ code: string;
3511
+ } | null;
3512
+ is_primary: boolean;
3513
+ }>;
3514
+ metadata: Record<string, any>;
3515
+ created_at: Date | string;
3516
+ updated_at: Date | string;
3517
+ }
3518
+ export { UserSyncResponse }
3519
+ export { UserSyncResponse as UserSyncResponse_alias_1 }
3520
+ export { UserSyncResponse as UserSyncResponse_alias_2 }
3521
+
3522
+ /**
3523
+ * Verify OTP Request
3524
+ */
3525
+ declare interface VerifyOTPRequest {
3526
+ otp_id: string;
3527
+ code: string;
3528
+ }
3529
+ export { VerifyOTPRequest }
3530
+ export { VerifyOTPRequest as VerifyOTPRequest_alias_1 }
3531
+ export { VerifyOTPRequest as VerifyOTPRequest_alias_2 }
3532
+
3533
+ /**
3534
+ * Verify OTP Response
3535
+ */
3536
+ declare interface VerifyOTPResponse {
3537
+ verified: boolean;
3538
+ }
3539
+ export { VerifyOTPResponse }
3540
+ export { VerifyOTPResponse as VerifyOTPResponse_alias_1 }
3541
+ export { VerifyOTPResponse as VerifyOTPResponse_alias_2 }
3542
+
3543
+ declare class WebhookAPI {
3544
+ private readonly axios;
3545
+ constructor(axios: AxiosInstance);
3546
+ /**
3547
+ * ส่ง webhook request ผ่าน proxy endpoint
3548
+ *
3549
+ * @description
3550
+ * - ส่ง webhook request ไปยัง external URL ผ่านระบบ proxy
3551
+ * - ระบบจะสร้าง webhook_log และยิง webhook ออกไปให้
3552
+ * - รองรับ retry mechanism อัตโนมัติ
3553
+ * - ส่ง async: true เพื่อยิงทันทีและรับ result (http_status, response_body) ใน response
3554
+ *
3555
+ * @example
3556
+ * ```typescript
3557
+ * // ส่ง webhook request (โหมดปกติ - ได้ webhook_log_id กลับมา แล้วค่อย getStatus ตรวจสอบ)
3558
+ * const result = await authClient.webhook.proxy({
3559
+ * webhook_url: 'https://api.example.com/webhooks/users',
3560
+ * event_type: 'user.created',
3561
+ * payload: {
3562
+ * data: { id: 'user-123', email: 'user@example.com' },
3563
+ * object: 'event',
3564
+ * type: 'user.created'
3565
+ * },
3566
+ * headers: { 'Authorization': 'Bearer token' },
3567
+ * secret: 'webhook-secret',
3568
+ * timeout_ms: 30000,
3569
+ * max_retries: 3
3570
+ * });
3571
+ * console.log('Webhook Log ID:', result.webhook_log_id);
3572
+ *
3573
+ * // โหมด async: true - ยิงทันทีและได้ result กลับใน response (ไม่ต้อง getStatus)
3574
+ * const resultAsync = await authClient.webhook.proxy({
3575
+ * webhook_url: 'https://api.example.com/webhooks/users',
3576
+ * event_type: 'user.created',
3577
+ * payload: { data: { id: 'user-123' }, object: 'event', type: 'user.created' },
3578
+ * async: true
3579
+ * });
3580
+ * if (resultAsync.status === 'success') {
3581
+ * console.log('HTTP Status:', resultAsync.http_status);
3582
+ * console.log('Response Body:', resultAsync.response_body);
3583
+ * console.log('Execution Time:', resultAsync.execution_time_ms, 'ms');
3584
+ * } else {
3585
+ * console.error('Failed:', resultAsync.error_message);
3586
+ * }
3587
+ * ```
3588
+ */
3589
+ proxy(request: WebhookProxyRequest): Promise<WebhookProxyResponse>;
3590
+ /**
3591
+ * ดึง webhook log detail ตาม ID
3592
+ *
3593
+ * @description
3594
+ * - ดึงข้อมูล webhook log ตาม ID ที่ส่งกลับมาจาก proxy()
3595
+ * - แสดง status, response, error message, และข้อมูลอื่นๆ
3596
+ * - สามารถดึงได้เฉพาะ webhook logs ของ application ที่ authenticate อยู่เท่านั้น
3597
+ *
3598
+ * @example
3599
+ * ```typescript
3600
+ * // ดึง webhook log detail
3601
+ * const log = await authClient.webhook.getStatus('log-123e4567-e89b-12d3-a456-426614174000');
3602
+ *
3603
+ * console.log('Status:', log.status); // 'success', 'failed', 'pending', 'retrying'
3604
+ * console.log('HTTP Status:', log.http_status); // 200, 404, 500, etc.
3605
+ * console.log('Response Body:', log.response_body);
3606
+ * console.log('Error:', log.error_message);
3607
+ * console.log('Execution Time:', log.execution_time_ms, 'ms');
3608
+ * console.log('Retry Count:', log.retry_count);
3609
+ *
3610
+ * // ตรวจสอบว่า webhook สำเร็จหรือไม่
3611
+ * if (log.status === 'success') {
3612
+ * console.log('Webhook delivered successfully!');
3613
+ * } else if (log.status === 'failed') {
3614
+ * console.error('Webhook failed:', log.error_message);
3615
+ * }
3616
+ * ```
3617
+ */
3618
+ getStatus(webhookLogId: string): Promise<WebhookLogDetail>;
3619
+ }
3620
+ export { WebhookAPI }
3621
+ export { WebhookAPI as WebhookAPI_alias_1 }
3622
+ export { WebhookAPI as WebhookAPI_alias_2 }
3623
+
3624
+ /**
3625
+ * Webhook Log Detail
3626
+ * ข้อมูล detail ของ webhook log
3627
+ */
3628
+ declare interface WebhookLogDetail {
3629
+ /** รหัส webhook log */
3630
+ id: string;
3631
+ /** รหัส webhook config ที่ใช้ (optional สำหรับ proxy webhooks) */
3632
+ webhook_config_id?: string;
3633
+ /** รหัส application ที่เกี่ยวข้อง */
3634
+ application_id?: string;
3635
+ /** แหล่งที่มาของ webhook (internal/external) */
3636
+ source: 'internal' | 'external';
3637
+ /** URL ที่ส่ง webhook ไป */
3638
+ webhook_url: string;
3639
+ /** ประเภทของ event */
3640
+ event_type: string;
3641
+ /** Payload ที่ส่งไป */
3642
+ payload: Record<string, any>;
3643
+ /** สถานะของการส่ง webhook */
3644
+ status: 'pending' | 'success' | 'failed' | 'retrying';
3645
+ /** HTTP status code ที่ได้รับกลับมา */
3646
+ http_status?: number;
3647
+ /** HTTP request headers จาก external ที่เรียกเข้ามา */
3648
+ request_headers?: Record<string, string>;
3649
+ /** Headers ที่จะใช้ส่งไปกับ axios (จาก DTO หรือ webhook config) */
3650
+ headers?: Record<string, string>;
3651
+ /** Headers ที่ได้รับกลับมาจาก response */
3652
+ response_headers?: Record<string, string>;
3653
+ /** Response body ที่ได้รับกลับมา */
3654
+ response_body?: string;
3655
+ /** Error message หากเกิดข้อผิดพลาด */
3656
+ error_message?: string;
3657
+ /** จำนวนครั้งที่ retry แล้ว */
3658
+ retry_count: number;
3659
+ /** เวลาที่จะ retry ครั้งถัดไป */
3660
+ next_retry_at?: Date | string;
3661
+ /** เวลาที่เสร็จสิ้น (สำเร็จหรือล้มเหลว) */
3662
+ completed_at?: Date | string;
3663
+ /** เวลาที่ใช้ในการส่ง request (milliseconds) */
3664
+ execution_time_ms?: number;
3665
+ /** วันที่สร้าง */
3666
+ created_at: Date | string;
3667
+ /** วันที่อัพเดทล่าสุด */
3668
+ updated_at: Date | string;
3669
+ }
3670
+ export { WebhookLogDetail }
3671
+ export { WebhookLogDetail as WebhookLogDetail_alias_1 }
3672
+ export { WebhookLogDetail as WebhookLogDetail_alias_2 }
3673
+ export { WebhookLogDetail as WebhookLogDetail_alias_3 }
3674
+
3675
+ /**
3676
+ * Webhook Types for Auth SDK
3677
+ *
3678
+ * @description Types สำหรับ webhook proxy operations ใน SDK
3679
+ */
3680
+ /**
3681
+ * Webhook Proxy Request
3682
+ * สำหรับส่ง webhook request ผ่าน proxy endpoint
3683
+ */
3684
+ declare interface WebhookProxyRequest {
3685
+ /** URL ปลายทางที่จะส่ง webhook ไป */
3686
+ webhook_url: string;
3687
+ /** ประเภทของ event */
3688
+ event_type: string;
3689
+ /** Payload ที่จะส่งไป */
3690
+ payload: Record<string, any>;
3691
+ /** HTTP headers ที่จะส่งไปกับ request */
3692
+ headers?: Record<string, string>;
3693
+ /** Secret key สำหรับ HMAC signature */
3694
+ secret?: string;
3695
+ /** Timeout ในการส่ง request (milliseconds) */
3696
+ timeout_ms?: number;
3697
+ /** จำนวนครั้งสูงสุดที่จะ retry */
3698
+ max_retries?: number;
3699
+ /** ถ้า true = ยิงทันทีและส่ง result (http_status, response_body) กลับใน response */
3700
+ async?: boolean;
3701
+ }
3702
+ export { WebhookProxyRequest }
3703
+ export { WebhookProxyRequest as WebhookProxyRequest_alias_1 }
3704
+ export { WebhookProxyRequest as WebhookProxyRequest_alias_2 }
3705
+ export { WebhookProxyRequest as WebhookProxyRequest_alias_3 }
3706
+
3707
+ /**
3708
+ * Webhook Proxy Response
3709
+ * Response หลังจากส่ง webhook request
3710
+ * เมื่อส่ง async: true จะมี http_status, response_body, execution_time_ms (และ error_message ถ้าล้มเหลว)
3711
+ */
3712
+ declare interface WebhookProxyResponse {
3713
+ /** รหัส webhook log ที่สร้างขึ้น */
3714
+ webhook_log_id: string;
3715
+ /** สถานะการส่ง webhook */
3716
+ status: 'pending' | 'success' | 'failed' | 'retrying';
3717
+ /** ข้อความอธิบาย */
3718
+ message: string;
3719
+ /** HTTP status จากปลายทาง (เมื่อ async=true) */
3720
+ http_status?: number;
3721
+ /** Response body จากปลายทาง (เมื่อ async=true) */
3722
+ response_body?: unknown;
3723
+ /** เวลาที่ใช้ส่ง request มิลลิวินาที (เมื่อ async=true) */
3724
+ execution_time_ms?: number;
3725
+ /** ข้อความ error (เมื่อ async=true และล้มเหลว) */
3726
+ error_message?: string;
3727
+ }
3728
+ export { WebhookProxyResponse }
3729
+ export { WebhookProxyResponse as WebhookProxyResponse_alias_1 }
3730
+ export { WebhookProxyResponse as WebhookProxyResponse_alias_2 }
3731
+ export { WebhookProxyResponse as WebhookProxyResponse_alias_3 }
3732
+
3733
+ declare class WorkflowAPI {
3734
+ private readonly axios;
3735
+ constructor(axios: AxiosInstance);
3736
+ /**
3737
+ * Get workflow instance by ID
3738
+ *
3739
+ * @example
3740
+ * ```typescript
3741
+ * const instance = await authClient.workflow.getInstance("wf-inst-123");
3742
+ * ```
3743
+ */
3744
+ getInstance(instanceId: string): Promise<WorkflowInstance>;
3745
+ /**
3746
+ * Create a new workflow instance
3747
+ *
3748
+ * @example
3749
+ * ```typescript
3750
+ * const instance = await authClient.workflow.createInstance({
3751
+ * workflow_definition_id: "wf-def-123",
3752
+ * document_id: "doc-123",
3753
+ * document_type: "purchase_request",
3754
+ * document_title: "ขอซื้อคอมพิวเตอร์",
3755
+ * priority: "high",
3756
+ * position_id: "pos-123",
3757
+ * form_data: {
3758
+ * amount: 150000,
3759
+ * items: ["Laptop", "Monitor"]
3760
+ * },
3761
+ * user_id: "user-123"
3762
+ * });
3763
+ * ```
3764
+ */
3765
+ createInstance(instanceData: CreateWorkflowInstanceRequest): Promise<WorkflowInstance>;
3766
+ /**
3767
+ * Update workflow instance
3768
+ *
3769
+ * @example
3770
+ * ```typescript
3771
+ * const updatedInstance = await authClient.workflow.updateInstance("wf-inst-123", {
3772
+ * document_title: "ขอซื้อคอมพิวเตอร์ (แก้ไข)",
3773
+ * priority: "urgent"
3774
+ * });
3775
+ * ```
3776
+ */
3777
+ updateInstance(instanceId: string, instanceData: UpdateWorkflowInstanceRequest): Promise<WorkflowInstance>;
3778
+ /**
3779
+ * Search workflow instances with pagination and filters
3780
+ *
3781
+ * @example
3782
+ * ```typescript
3783
+ * const result = await authClient.workflow.searchInstances({
3784
+ * search: "ขอซื้อ",
3785
+ * page: 1,
3786
+ * limit: 20,
3787
+ * sort_by: "created_at",
3788
+ * sort_order: "desc",
3789
+ * filters: {
3790
+ * status: ["running", "pending"],
3791
+ * priority: ["high", "urgent"]
3792
+ * }
3793
+ * });
3794
+ *
3795
+ * // Access paginated data
3796
+ * console.log(result.data); // WorkflowInstance[]
3797
+ * console.log(result.pagination.total); // Total count
3798
+ * console.log(result.pagination.has_next); // Has next page
3799
+ * ```
3800
+ */
3801
+ searchInstances(params?: WorkflowInstanceSearchParams): Promise<ApiPaginatedResponse<WorkflowInstance>>;
3802
+ /**
3803
+ * Get workflow task by ID
3804
+ *
3805
+ * @example
3806
+ * ```typescript
3807
+ * const task = await authClient.workflow.getTask("task-123");
3808
+ * ```
3809
+ */
3810
+ getTask(taskId: string): Promise<WorkflowTask>;
3811
+ /**
3812
+ * Get user tasks with pagination and filters
3813
+ *
3814
+ * @example
3815
+ * ```typescript
3816
+ * const result = await authClient.workflow.getUserTasks({
3817
+ * status: ["assigned", "in_progress"],
3818
+ * priority: ["high"],
3819
+ * page: 1,
3820
+ * limit: 20
3821
+ * });
3822
+ *
3823
+ * // Access paginated data
3824
+ * console.log(result.data); // WorkflowTask[]
3825
+ * console.log(result.pagination.total); // Total count
3826
+ * ```
3827
+ */
3828
+ getUserTasks(params?: WorkflowTaskSearchParams): Promise<ApiPaginatedResponse<WorkflowTask>>;
3829
+ /**
3830
+ * Perform action on workflow task (approve, reject, delegate, escalate, etc.)
3831
+ *
3832
+ * @example
3833
+ * ```typescript
3834
+ * // Approve task
3835
+ * const result = await authClient.workflow.performTaskAction("task-123", {
3836
+ * action_key: "approve",
3837
+ * comments: "อนุมัติตามขั้นตอน"
3838
+ * });
3839
+ *
3840
+ * // Reject task
3841
+ * const result = await authClient.workflow.performTaskAction("task-123", {
3842
+ * action_key: "reject",
3843
+ * comments: "ไม่ผ่านตามเงื่อนไข",
3844
+ * reason: "งบประมาณไม่เพียงพอ"
3845
+ * });
3846
+ *
3847
+ * // Delegate task
3848
+ * const result = await authClient.workflow.performTaskAction("task-123", {
3849
+ * action_key: "delegate",
3850
+ * delegate_to_user_id: "user-456",
3851
+ * comments: "มอบหมายให้ผู้จัดการพิจารณา"
3852
+ * });
3853
+ * ```
3854
+ */
3855
+ performTaskAction(taskId: string, actionData: TaskActionRequest): Promise<WorkflowTask>;
3856
+ /**
3857
+ * Get workflow definition by ID
3858
+ *
3859
+ * @example
3860
+ * ```typescript
3861
+ * const definition = await authClient.workflow.getDefinition("wf-def-123");
3862
+ * ```
3863
+ */
3864
+ getDefinition(definitionId: string): Promise<WorkflowDefinition>;
3865
+ /**
3866
+ * Search workflow definitions with pagination and filters
3867
+ *
3868
+ * @example
3869
+ * ```typescript
3870
+ * const result = await authClient.workflow.searchDefinitions({
3871
+ * search: "อนุมัติ",
3872
+ * page: 1,
3873
+ * limit: 20,
3874
+ * filters: {
3875
+ * status: ["active"]
3876
+ * }
3877
+ * });
3878
+ *
3879
+ * // Access paginated data
3880
+ * console.log(result.data); // WorkflowDefinition[]
3881
+ * console.log(result.pagination.total); // Total count
3882
+ * ```
3883
+ */
3884
+ searchDefinitions(params?: {
3885
+ search?: string;
3886
+ page?: number;
3887
+ limit?: number;
3888
+ filters?: {
3889
+ status?: string[];
3890
+ organization_id?: string;
3891
+ document_type_id?: string;
3892
+ [key: string]: any;
3893
+ };
3894
+ }): Promise<ApiPaginatedResponse<WorkflowDefinition>>;
3895
+ }
3896
+ export { WorkflowAPI }
3897
+ export { WorkflowAPI as WorkflowAPI_alias_1 }
3898
+ export { WorkflowAPI as WorkflowAPI_alias_2 }
3899
+
3900
+ /**
3901
+ * Workflow Definition Response
3902
+ */
3903
+ declare interface WorkflowDefinition {
3904
+ id: string;
3905
+ name: string;
3906
+ display_name: string;
3907
+ description?: string;
3908
+ version: number;
3909
+ status: string;
3910
+ organization_ids: string[];
3911
+ document_type_ids: string[];
3912
+ nodes: Array<{
3913
+ node_id: string;
3914
+ node_name: string;
3915
+ node_type: 'start' | 'approval' | 'decision' | 'end';
3916
+ [key: string]: any;
3917
+ }>;
3918
+ edges: Array<{
3919
+ edge_id: string;
3920
+ from_node: string;
3921
+ to_node: string;
3922
+ conditions?: string;
3923
+ [key: string]: any;
3924
+ }>;
3925
+ settings?: Record<string, any>;
3926
+ nodes_count: number;
3927
+ edges_count: number;
3928
+ approval_nodes_count: number;
3929
+ decision_nodes_count: number;
3930
+ estimated_duration_hours?: number;
3931
+ complexity_level: 'simple' | 'medium' | 'complex';
3932
+ created_at: Date;
3933
+ updated_at: Date;
3934
+ created_by?: {
3935
+ id: string;
3936
+ name: string;
3937
+ email: string;
3938
+ };
3939
+ [key: string]: any;
3940
+ }
3941
+ export { WorkflowDefinition }
3942
+ export { WorkflowDefinition as WorkflowDefinition_alias_1 }
3943
+ export { WorkflowDefinition as WorkflowDefinition_alias_2 }
3944
+
3945
+ /**
3946
+ * Workflow Types
3947
+ *
3948
+ * Type definitions for workflow operations
3949
+ */
3950
+ /**
3951
+ * Workflow Instance Response
3952
+ */
3953
+ declare interface WorkflowInstance {
3954
+ id: string;
3955
+ workflow_definition_id: string;
3956
+ workflow_definition_name: string;
3957
+ document_id: string;
3958
+ document_title: string;
3959
+ requester_id: string;
3960
+ requester_name: string;
3961
+ current_node_id?: string;
3962
+ current_node_name?: string;
3963
+ status: string;
3964
+ priority: string;
3965
+ progress_percentage: number;
3966
+ started_at?: Date;
3967
+ completed_at?: Date;
3968
+ due_date: Date;
3969
+ escalation_count: number;
3970
+ retry_count: number;
3971
+ created_at: Date;
3972
+ updated_at: Date;
3973
+ final_result?: 'approved' | 'rejected' | 'cancelled' | 'expired';
3974
+ final_decision_by?: string;
3975
+ final_decision_by_name?: string;
3976
+ final_decision_at?: Date;
3977
+ performance_summary?: {
3978
+ total_runtime_hours: number;
3979
+ nodes_completed: number;
3980
+ nodes_remaining: number;
3981
+ avg_node_time_hours: number;
3982
+ sla_compliance: boolean;
3983
+ time_remaining_hours?: number;
3984
+ completion_probability?: number;
3985
+ completion_efficiency?: number;
3986
+ };
3987
+ current_activity?: {
3988
+ description: string;
3989
+ assigned_to?: string;
3990
+ assigned_to_name?: string;
3991
+ waiting_since?: Date;
3992
+ expected_completion?: Date;
3993
+ status: 'waiting_approval' | 'processing' | 'evaluating' | 'on_hold' | 'escalating';
3994
+ can_escalate?: boolean;
3995
+ can_remind?: boolean;
3996
+ blocking_reason?: string;
3997
+ };
3998
+ workflow_path?: Array<{
3999
+ node_id: string;
4000
+ node_name: string;
4001
+ node_type: 'start' | 'approval' | 'decision' | 'end';
4002
+ status: 'pending' | 'running' | 'completed' | 'skipped' | 'failed';
4003
+ started_at?: Date;
4004
+ completed_at?: Date;
4005
+ approved_by_name?: string;
4006
+ assigned_to_name?: string;
4007
+ approval_result?: 'approved' | 'rejected' | 'returned';
4008
+ approvers?: Array<{
4009
+ user_id: string;
4010
+ name: string;
4011
+ email?: string;
4012
+ task_id?: string;
4013
+ status: 'pending' | 'completed' | 'rejected';
4014
+ }>;
4015
+ result?: string;
4016
+ }>;
4017
+ approvers?: Array<{
4018
+ user_id: string;
4019
+ name: string;
4020
+ email?: string;
4021
+ task_id?: string;
4022
+ status?: 'pending' | 'completed' | 'rejected';
4023
+ }>;
4024
+ next_approvers?: Array<{
4025
+ user_id: string;
4026
+ name: string;
4027
+ email?: string;
4028
+ task_title: string;
4029
+ node_id?: string;
4030
+ }>;
4031
+ [key: string]: any;
4032
+ }
4033
+ export { WorkflowInstance }
4034
+ export { WorkflowInstance as WorkflowInstance_alias_1 }
4035
+ export { WorkflowInstance as WorkflowInstance_alias_2 }
4036
+
4037
+ /**
4038
+ * Workflow Instance Search Params
4039
+ */
4040
+ declare interface WorkflowInstanceSearchParams {
4041
+ search?: string;
4042
+ page?: number;
4043
+ limit?: number;
4044
+ sort_by?: string;
4045
+ sort_order?: 'asc' | 'desc';
4046
+ filters?: {
4047
+ status?: string[];
4048
+ priority?: string[];
4049
+ workflow_definition_id?: string;
4050
+ requester_id?: string;
4051
+ current_node_id?: string;
4052
+ [key: string]: any;
4053
+ };
4054
+ }
4055
+ export { WorkflowInstanceSearchParams }
4056
+ export { WorkflowInstanceSearchParams as WorkflowInstanceSearchParams_alias_1 }
4057
+ export { WorkflowInstanceSearchParams as WorkflowInstanceSearchParams_alias_2 }
4058
+
4059
+ /**
4060
+ * Workflow Task Response
4061
+ */
4062
+ declare interface WorkflowTask {
4063
+ id: string;
4064
+ workflow_instance_id: string;
4065
+ node_id: string;
4066
+ task_type: string;
4067
+ task_title: string;
4068
+ task_description?: string;
4069
+ assigned_to: string;
4070
+ assignee_id?: string;
4071
+ assignee_code?: string;
4072
+ assignee_name: string;
4073
+ assignee_email?: string;
4074
+ status: string;
4075
+ priority: string;
4076
+ assigned_at: Date;
4077
+ due_date?: Date;
4078
+ completed_at?: Date;
4079
+ available_actions?: Array<{
4080
+ action_key: string;
4081
+ action_type: string;
4082
+ action_label: string;
4083
+ requires_comment: boolean;
4084
+ }>;
4085
+ requires_comment: boolean;
4086
+ can_delegate: boolean;
4087
+ workflow_title?: string;
4088
+ created_at: Date;
4089
+ updated_at: Date;
4090
+ [key: string]: any;
4091
+ }
4092
+ export { WorkflowTask }
4093
+ export { WorkflowTask as WorkflowTask_alias_1 }
4094
+ export { WorkflowTask as WorkflowTask_alias_2 }
4095
+
4096
+ /**
4097
+ * Workflow Task Search Params
4098
+ */
4099
+ declare interface WorkflowTaskSearchParams {
4100
+ status?: string[];
4101
+ priority?: string[];
4102
+ workflow_instance_id?: string;
4103
+ assigned_to?: string;
4104
+ page?: number;
4105
+ limit?: number;
4106
+ sort_by?: string;
4107
+ sort_order?: 'asc' | 'desc';
4108
+ }
4109
+ export { WorkflowTaskSearchParams }
4110
+ export { WorkflowTaskSearchParams as WorkflowTaskSearchParams_alias_1 }
4111
+ export { WorkflowTaskSearchParams as WorkflowTaskSearchParams_alias_2 }
4112
+
4113
+ export { }