win-portal-auth-sdk 1.5.7 → 1.6.1

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.
Files changed (38) hide show
  1. package/README.md +135 -0
  2. package/dist/client/api/auth.api.d.ts.map +1 -1
  3. package/dist/client/api/email.api.d.ts +8 -8
  4. package/dist/client/api/email.api.d.ts.map +1 -1
  5. package/dist/client/api/email.api.js +6 -10
  6. package/dist/client/api/index.d.ts +4 -0
  7. package/dist/client/api/index.d.ts.map +1 -1
  8. package/dist/client/api/index.js +7 -1
  9. package/dist/client/api/organization.api.d.ts +73 -0
  10. package/dist/client/api/organization.api.d.ts.map +1 -0
  11. package/dist/client/api/organization.api.js +124 -0
  12. package/dist/client/api/system-config.api.d.ts.map +1 -1
  13. package/dist/client/api/user.api.d.ts.map +1 -1
  14. package/dist/client/api/user.api.js +1 -3
  15. package/dist/client/api/webhook.api.d.ts +89 -0
  16. package/dist/client/api/webhook.api.d.ts.map +1 -0
  17. package/dist/client/api/webhook.api.js +97 -0
  18. package/dist/client/api/workflow.api.d.ts +178 -0
  19. package/dist/client/api/workflow.api.d.ts.map +1 -0
  20. package/dist/client/api/workflow.api.js +224 -0
  21. package/dist/client/auth-client.d.ts +4 -1
  22. package/dist/client/auth-client.d.ts.map +1 -1
  23. package/dist/client/auth-client.js +5 -1
  24. package/dist/types/email.types.d.ts +7 -0
  25. package/dist/types/email.types.d.ts.map +1 -1
  26. package/dist/types/index.d.ts +4 -0
  27. package/dist/types/index.d.ts.map +1 -1
  28. package/dist/types/index.js +8 -0
  29. package/dist/types/organization.types.d.ts +104 -0
  30. package/dist/types/organization.types.d.ts.map +1 -0
  31. package/dist/types/organization.types.js +19 -0
  32. package/dist/types/webhook.types.d.ts +93 -0
  33. package/dist/types/webhook.types.d.ts.map +1 -0
  34. package/dist/types/webhook.types.js +7 -0
  35. package/dist/types/workflow.types.d.ts +234 -0
  36. package/dist/types/workflow.types.d.ts.map +1 -0
  37. package/dist/types/workflow.types.js +7 -0
  38. package/package.json +1 -1
package/README.md CHANGED
@@ -182,6 +182,88 @@ const verifyResult = await authClient.otp.verifyOTP({
182
182
  if (verifyResult.verified) {
183
183
  console.log('OTP verified successfully');
184
184
  }
185
+
186
+ // Email Service (for external applications)
187
+ // Send email with template
188
+ await authClient.email.sendEmailWithTemplate(
189
+ 'welcome_email',
190
+ { userName: 'สมชาย ใจดี', activationLink: 'https://app.com/activate?token=xxx' },
191
+ 'user@example.com',
192
+ { recipient_name: 'สมชาย ใจดี', language: 'th' }
193
+ );
194
+
195
+ // Send email with raw HTML
196
+ await authClient.email.sendRawEmail(
197
+ '<h1>ยินดีต้อนรับ</h1><p>ขอบคุณที่สมัครสมาชิก</p>',
198
+ 'ยินดีต้อนรับสู่ระบบ',
199
+ 'user@example.com',
200
+ { text_body: 'ยินดีต้อนรับ ขอบคุณที่สมัครสมาชิก' }
201
+ );
202
+
203
+ // Todo Management
204
+ const todo = await authClient.todo.create({
205
+ title: 'ซื้อของใช้ในบ้าน',
206
+ priority: 'normal',
207
+ user_id: 'user-123',
208
+ description: 'ซื้อน้ำยาล้างจาน, กระดาษทิชชู่',
209
+ due_date: new Date('2024-01-20'),
210
+ category: 'shopping',
211
+ labels: ['บ้าน', 'จำเป็น'],
212
+ is_send_notification: true,
213
+ });
214
+
215
+ // Workflow Management
216
+ // Create workflow instance
217
+ const workflowInstance = await authClient.workflow.createInstance({
218
+ workflow_definition_id: 'wf-def-123',
219
+ document_id: 'doc-123',
220
+ document_type: 'purchase_request',
221
+ document_title: 'ขอซื้อคอมพิวเตอร์',
222
+ priority: 'high',
223
+ form_data: { amount: 150000, items: ['Laptop', 'Monitor'] },
224
+ });
225
+
226
+ // Get user tasks
227
+ const userTasks = await authClient.workflow.getUserTasks({
228
+ status: ['assigned', 'in_progress'],
229
+ page: 1,
230
+ limit: 20,
231
+ });
232
+
233
+ // Perform task action (approve/reject/delegate)
234
+ await authClient.workflow.performTaskAction('task-123', {
235
+ action_key: 'approve',
236
+ comments: 'อนุมัติตามขั้นตอน',
237
+ });
238
+
239
+ // Organization Management
240
+ // Search organizations
241
+ const organizations = await authClient.organization.search({
242
+ search: 'แผนก',
243
+ page: 1,
244
+ limit: 20,
245
+ });
246
+
247
+ // Get organization hierarchy
248
+ const ancestors = await authClient.organization.getAncestors('org-123');
249
+ const reportingLine = await authClient.organization.getReportingLine('org-123');
250
+ const users = await authClient.organization.getUsers('org-123', true); // include descendants
251
+
252
+ // Webhook Proxy (for external applications)
253
+ // Send webhook through proxy
254
+ const webhookResult = await authClient.webhook.proxy({
255
+ webhook_url: 'https://api.example.com/webhooks/users',
256
+ event_type: 'user.created',
257
+ payload: { data: { id: 'user-123', email: 'user@example.com' } },
258
+ headers: { Authorization: 'Bearer token' },
259
+ secret: 'webhook-secret',
260
+ timeout_ms: 30000,
261
+ max_retries: 3,
262
+ });
263
+
264
+ // Check webhook status
265
+ const webhookLog = await authClient.webhook.getStatus(webhookResult.webhook_log_id);
266
+ console.log('Status:', webhookLog.status); // 'success', 'failed', 'pending'
185
267
  ```
186
268
 
187
269
  **For custom endpoints, use direct HTTP methods:**
@@ -380,6 +462,7 @@ const client = new AuthClient({
380
462
  - `user.create(userData)` - Create new user
381
463
  - `user.update(userId, userData)` - Update user
382
464
  - `user.delete(userId)` - Delete user
465
+ - `user.sync(params?)` - Sync users for external applications (paginated)
383
466
 
384
467
  **LINE Messaging:**
385
468
 
@@ -424,6 +507,58 @@ const client = new AuthClient({
424
507
  - Returns: `{ verified: boolean }`
425
508
  - Requires API Key authentication
426
509
 
510
+ **Email Service (for external applications):**
511
+
512
+ - `email.sendEmail(request)` - Send email (auto-detect Template Mode or Raw HTML Mode)
513
+ - `email.sendEmailWithTemplate(templateCode, templateData, recipient, options?)` - Send email with template
514
+ - `email.sendRawEmail(htmlBody, subject, recipient, options?)` - Send email with raw HTML
515
+ - Supports CC, BCC, attachments, priority, scheduled delivery
516
+ - Requires API Key authentication
517
+
518
+ **Todo Management:**
519
+
520
+ - `todo.create(todoData)` - Create a new todo item
521
+
522
+ **Workflow Management:**
523
+
524
+ - `workflow.getInstance(instanceId)` - Get workflow instance by ID
525
+ - `workflow.createInstance(instanceData)` - Create a new workflow instance
526
+ - `workflow.updateInstance(instanceId, instanceData)` - Update workflow instance
527
+ - `workflow.searchInstances(params?)` - Search workflow instances with pagination
528
+ - `workflow.getTask(taskId)` - Get workflow task by ID
529
+ - `workflow.getUserTasks(params?)` - Get user tasks with pagination and filters
530
+ - `workflow.performTaskAction(taskId, actionData)` - Perform action on task (approve/reject/delegate/escalate)
531
+ - `workflow.getDefinition(definitionId)` - Get workflow definition by ID
532
+ - `workflow.searchDefinitions(params?)` - Search workflow definitions with pagination
533
+
534
+ **Organization Management:**
535
+
536
+ - `organization.search(params?)` - Search organizations with pagination
537
+ - `organization.get(id)` - Get organization by ID
538
+ - `organization.create(data)` - Create new organization
539
+ - `organization.update(id, data)` - Update organization
540
+ - `organization.delete(id)` - Delete organization
541
+ - `organization.getUsers(id, includeDescendants?)` - Get organization users
542
+ - `organization.getAncestors(id, includeRoot?)` - Get parent organizations at all levels
543
+ - `organization.getDirectSupervisor(id)` - Get immediate supervisor/parent organization
544
+ - `organization.getPath(id)` - Get full path from root to organization
545
+ - `organization.getReportingLine(id)` - Get reporting line (hierarchical and functional)
546
+ - `organization.getSiblings(id, includeSelf?)` - Get sibling organizations
547
+ - `organization.getLevel(id)` - Get organization level
548
+ - `organization.getCommonAncestor(orgA, orgB)` - Get lowest common ancestor
549
+ - `organization.isAncestorOf(ancestorId, descendantId)` - Check if organization is ancestor
550
+
551
+ **Webhook Proxy (for external applications):**
552
+
553
+ - `webhook.proxy(request)` - Send webhook request through proxy endpoint
554
+ - Supports retry mechanism, custom headers, timeout configuration
555
+ - Returns: `{ webhook_log_id, status }`
556
+ - Requires API Key authentication
557
+
558
+ - `webhook.getStatus(webhookLogId)` - Get webhook log detail by ID
559
+ - Returns: `{ status, http_status, response_body, error_message, execution_time_ms, retry_count, ... }`
560
+ - Requires API Key authentication
561
+
427
562
  #### Utility Methods
428
563
 
429
564
  - `setToken(token, type?)` - Set authentication token
@@ -1 +1 @@
1
- {"version":3,"file":"auth.api.d.ts","sourceRoot":"","sources":["../../../src/client/api/auth.api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAEL,WAAW,EACX,IAAI,EAGL,MAAM,aAAa,CAAC;AAErB,qBAAa,OAAO;IACN,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,UAAU;IAEtC;;OAEG;IACG,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAMlE;;OAEG;IACG,MAAM,IAAI,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAK5C;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAK9B;;;;;;;;;;;;OAYG;IACG,cAAc,IAAI,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAKlD;;;;;;;;;;;;;;;;;OAiBG;IACG,gBAAgB,CACpB,YAAY,EAAE,MAAM,EACpB,OAAO,CAAC,EAAE;QACR,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,GACA,OAAO,CAAC,WAAW,CAAC;IAevB;;;OAGG;IACG,SAAS,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;QAC7C,MAAM,EAAE,MAAM,CAAC;QACf,OAAO,EAAE,MAAM,CAAC;QAChB,YAAY,EAAE,MAAM,EAAE,CAAC;QACvB,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;IAcF;;OAEG;IACG,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,QA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B,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,WAAW,CAAC;IASvB;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC;QAAE,QAAQ,EAAE,OAAO,CAAA;KAAE,CAAC;IAKnD;;;OAGG;IACG,yBAAyB,IAAI,OAAO,CAAC;QACzC,YAAY,EAAE,MAAM,EAAE,CAAC;QACvB,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;CASH"}
@@ -9,7 +9,7 @@
9
9
  * @requires API Key authentication
10
10
  */
11
11
  import { AuthClient } from '../auth-client';
12
- import { SendEmailApiRequestDto, SendEmailApiResponseDto } from '../../types';
12
+ import { SendEmailRequest, SendEmailResponse } from '../../types';
13
13
  /**
14
14
  * Email API
15
15
  *
@@ -52,8 +52,8 @@ export declare class EmailAPI {
52
52
  /**
53
53
  * Send email (auto-detect Template Mode or Raw HTML Mode)
54
54
  *
55
- * @param request - SendEmailApiRequestDto
56
- * @returns SendEmailApiResponseDto
55
+ * @param request - SendEmailRequest
56
+ * @returns SendEmailResponse
57
57
  *
58
58
  * @example
59
59
  * ```typescript
@@ -72,7 +72,7 @@ export declare class EmailAPI {
72
72
  * });
73
73
  * ```
74
74
  */
75
- sendEmail(request: SendEmailApiRequestDto): Promise<SendEmailApiResponseDto>;
75
+ sendEmail(request: SendEmailRequest): Promise<SendEmailResponse>;
76
76
  /**
77
77
  * Send email with template (Template Mode - convenience method)
78
78
  *
@@ -80,7 +80,7 @@ export declare class EmailAPI {
80
80
  * @param templateData - Template data for rendering
81
81
  * @param recipient - Email address or user ID
82
82
  * @param options - Additional options (cc, bcc, attachments, etc.)
83
- * @returns SendEmailApiResponseDto
83
+ * @returns SendEmailResponse
84
84
  *
85
85
  * @example
86
86
  * ```typescript
@@ -122,7 +122,7 @@ export declare class EmailAPI {
122
122
  source?: string;
123
123
  related_entity_id?: string;
124
124
  related_entity_type?: string;
125
- }): Promise<SendEmailApiResponseDto>;
125
+ }): Promise<SendEmailResponse>;
126
126
  /**
127
127
  * Send email with raw HTML (Raw HTML Mode - convenience method)
128
128
  *
@@ -130,7 +130,7 @@ export declare class EmailAPI {
130
130
  * @param subject - Email subject
131
131
  * @param recipient - Email address or user ID
132
132
  * @param options - Additional options (text_body, cc, bcc, attachments, etc.)
133
- * @returns SendEmailApiResponseDto
133
+ * @returns SendEmailResponse
134
134
  *
135
135
  * @example
136
136
  * ```typescript
@@ -169,6 +169,6 @@ export declare class EmailAPI {
169
169
  source?: string;
170
170
  related_entity_id?: string;
171
171
  related_entity_type?: string;
172
- }): Promise<SendEmailApiResponseDto>;
172
+ }): Promise<SendEmailResponse>;
173
173
  }
174
174
  //# sourceMappingURL=email.api.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"email.api.d.ts","sourceRoot":"","sources":["../../../src/client/api/email.api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAe,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAE3F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,qBAAa,QAAQ;IACP,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,UAAU;IAEtC;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACG,SAAS,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAQlF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+BG;IACG,qBAAqB,CACzB,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACjC,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE;QACR,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;QACvB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,EAAE,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,YAAY,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;QAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,mBAAmB,CAAC,EAAE,MAAM,CAAC;KAC9B,GACA,OAAO,CAAC,iBAAiB,CAAC;IAqB7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;IACG,YAAY,CAChB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE;QACR,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;QACvB,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;QACxB,WAAW,CAAC,EAAE,KAAK,CAAC;YAClB,QAAQ,EAAE,MAAM,CAAC;YACjB,IAAI,EAAE,MAAM,CAAC;YACb,YAAY,CAAC,EAAE,MAAM,CAAC;SACvB,CAAC,CAAC;QACH,QAAQ,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,QAAQ,CAAC;QAChD,YAAY,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;QAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,mBAAmB,CAAC,EAAE,MAAM,CAAC;KAC9B,GACA,OAAO,CAAC,iBAAiB,CAAC;CAmB9B"}
@@ -54,8 +54,8 @@ class EmailAPI {
54
54
  /**
55
55
  * Send email (auto-detect Template Mode or Raw HTML Mode)
56
56
  *
57
- * @param request - SendEmailApiRequestDto
58
- * @returns SendEmailApiResponseDto
57
+ * @param request - SendEmailRequest
58
+ * @returns SendEmailResponse
59
59
  *
60
60
  * @example
61
61
  * ```typescript
@@ -85,7 +85,7 @@ class EmailAPI {
85
85
  * @param templateData - Template data for rendering
86
86
  * @param recipient - Email address or user ID
87
87
  * @param options - Additional options (cc, bcc, attachments, etc.)
88
- * @returns SendEmailApiResponseDto
88
+ * @returns SendEmailResponse
89
89
  *
90
90
  * @example
91
91
  * ```typescript
@@ -116,9 +116,7 @@ class EmailAPI {
116
116
  template_data: templateData,
117
117
  ...(options?.language && { language: options.language }),
118
118
  ...(options?.subject && { subject: options.subject }),
119
- ...(recipient.includes('@')
120
- ? { recipient_email: recipient }
121
- : { recipient_id: recipient }),
119
+ ...(recipient.includes('@') ? { recipient_email: recipient } : { recipient_id: recipient }),
122
120
  ...(options?.recipient_name && { recipient_name: options.recipient_name }),
123
121
  ...(options?.cc && { cc: options.cc }),
124
122
  ...(options?.bcc && { bcc: options.bcc }),
@@ -138,7 +136,7 @@ class EmailAPI {
138
136
  * @param subject - Email subject
139
137
  * @param recipient - Email address or user ID
140
138
  * @param options - Additional options (text_body, cc, bcc, attachments, etc.)
141
- * @returns SendEmailApiResponseDto
139
+ * @returns SendEmailResponse
142
140
  *
143
141
  * @example
144
142
  * ```typescript
@@ -165,9 +163,7 @@ class EmailAPI {
165
163
  const request = {
166
164
  html_body: htmlBody,
167
165
  subject,
168
- ...(recipient.includes('@')
169
- ? { recipient_email: recipient }
170
- : { recipient_id: recipient }),
166
+ ...(recipient.includes('@') ? { recipient_email: recipient } : { recipient_id: recipient }),
171
167
  ...(options?.recipient_name && { recipient_name: options.recipient_name }),
172
168
  ...(options?.text_body && { text_body: options.text_body }),
173
169
  ...(options?.cc && { cc: options.cc }),
@@ -20,4 +20,8 @@ export { UserAPI } from './user.api';
20
20
  export { OtpAPI } from './otp.api';
21
21
  export type { SendOTPRequest, SendOTPResponse, VerifyOTPRequest, VerifyOTPResponse } from './otp.api';
22
22
  export { EmailAPI } from './email.api';
23
+ export { WorkflowAPI } from './workflow.api';
24
+ export { OrganizationAPI } from './organization.api';
25
+ export { WebhookAPI } from './webhook.api';
26
+ export type { WebhookProxyRequest, WebhookProxyResponse, WebhookLogDetail } from '../../types/webhook.types';
23
27
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/api/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,YAAY,EAAE,0BAA0B,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,YAAY,EAAE,WAAW,EAAE,uBAAuB,EAAE,aAAa,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACpH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,YAAY,EACV,sBAAsB,EACtB,kBAAkB,EAClB,gBAAgB,EAChB,mBAAmB,EACnB,uBAAuB,EACvB,kBAAkB,EAClB,mBAAmB,EACnB,iCAAiC,GAClC,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,YAAY,EAAE,cAAc,EAAE,eAAe,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AACtG,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC"}
1
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rD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,YAAY,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC"}
@@ -5,7 +5,7 @@
5
5
  * Central export point for all API namespaces
6
6
  */
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.EmailAPI = exports.OtpAPI = exports.UserAPI = exports.TodoAPI = exports.LineAPI = exports.generateState = exports.generatePKCE = exports.OAuthAPI = exports.LicenseAPI = exports.EventLogApi = exports.FilesAPI = exports.SystemConfigAPI = exports.HealthAPI = exports.AuthAPI = void 0;
8
+ exports.WebhookAPI = exports.OrganizationAPI = exports.WorkflowAPI = exports.EmailAPI = exports.OtpAPI = exports.UserAPI = exports.TodoAPI = exports.LineAPI = exports.generateState = exports.generatePKCE = exports.OAuthAPI = exports.LicenseAPI = exports.EventLogApi = exports.FilesAPI = exports.SystemConfigAPI = exports.HealthAPI = exports.AuthAPI = void 0;
9
9
  var auth_api_1 = require("./auth.api");
10
10
  Object.defineProperty(exports, "AuthAPI", { enumerable: true, get: function () { return auth_api_1.AuthAPI; } });
11
11
  var health_api_1 = require("./health.api");
@@ -33,3 +33,9 @@ var otp_api_1 = require("./otp.api");
33
33
  Object.defineProperty(exports, "OtpAPI", { enumerable: true, get: function () { return otp_api_1.OtpAPI; } });
34
34
  var email_api_1 = require("./email.api");
35
35
  Object.defineProperty(exports, "EmailAPI", { enumerable: true, get: function () { return email_api_1.EmailAPI; } });
36
+ var workflow_api_1 = require("./workflow.api");
37
+ Object.defineProperty(exports, "WorkflowAPI", { enumerable: true, get: function () { return workflow_api_1.WorkflowAPI; } });
38
+ var organization_api_1 = require("./organization.api");
39
+ Object.defineProperty(exports, "OrganizationAPI", { enumerable: true, get: function () { return organization_api_1.OrganizationAPI; } });
40
+ var webhook_api_1 = require("./webhook.api");
41
+ Object.defineProperty(exports, "WebhookAPI", { enumerable: true, get: function () { return webhook_api_1.WebhookAPI; } });
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Organization API Client
3
+ *
4
+ * Handles organization data and hierarchy operations:
5
+ * - Search organizations
6
+ * - Get organization by ID
7
+ * - Create/Update/Delete
8
+ * - Hierarchy management (Ancestors, Descendants, Reporting Line)
9
+ */
10
+ import { AuthClient } from '../auth-client';
11
+ import { Organization, CreateOrganizationRequest, UpdateOrganizationRequest, OrganizationSearchParams, ApiPaginatedResponse, ReportingLineResponse, OrganizationLevelResponse, User } from '../../types';
12
+ export declare class OrganizationAPI {
13
+ private readonly client;
14
+ constructor(client: AuthClient);
15
+ /**
16
+ * Search organizations with pagination and filters
17
+ */
18
+ search(params?: OrganizationSearchParams): Promise<ApiPaginatedResponse<Organization>>;
19
+ /**
20
+ * Get organization by ID
21
+ */
22
+ get(id: string): Promise<Organization>;
23
+ /**
24
+ * Create a new organization
25
+ */
26
+ create(data: CreateOrganizationRequest): Promise<Organization>;
27
+ /**
28
+ * Update organization
29
+ */
30
+ update(id: string, data: UpdateOrganizationRequest): Promise<Organization>;
31
+ /**
32
+ * Delete organization
33
+ */
34
+ delete(id: string): Promise<boolean>;
35
+ /**
36
+ * Get organization users
37
+ * @param includeDescendants If true, returns users from all descendant organizations recursively
38
+ */
39
+ getUsers(id: string, includeDescendants?: boolean): Promise<User[]>;
40
+ /**
41
+ * Get ancestors (parent organizations at all levels)
42
+ */
43
+ getAncestors(id: string, includeRoot?: boolean): Promise<Organization[]>;
44
+ /**
45
+ * Get immediate supervisor/parent organization
46
+ */
47
+ getDirectSupervisor(id: string): Promise<Organization | null>;
48
+ /**
49
+ * Get full path from root to organization
50
+ */
51
+ getPath(id: string): Promise<Organization[]>;
52
+ /**
53
+ * Get reporting line (hierarchical and functional)
54
+ */
55
+ getReportingLine(id: string): Promise<ReportingLineResponse>;
56
+ /**
57
+ * Get sibling organizations (same parent)
58
+ */
59
+ getSiblings(id: string, includeSelf?: boolean): Promise<Organization[]>;
60
+ /**
61
+ * Get organization level
62
+ */
63
+ getLevel(id: string): Promise<OrganizationLevelResponse>;
64
+ /**
65
+ * Get lowest common ancestor of two organizations
66
+ */
67
+ getCommonAncestor(orgA: string, orgB: string): Promise<Organization | null>;
68
+ /**
69
+ * Check if an organization is an ancestor of another
70
+ */
71
+ isAncestorOf(ancestorId: string, descendantId: string): Promise<boolean>;
72
+ }
73
+ //# sourceMappingURL=organization.api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"organization.api.d.ts","sourceRoot":"","sources":["../../../src/client/api/organization.api.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EACL,YAAY,EACZ,yBAAyB,EACzB,yBAAyB,EACzB,wBAAwB,EACxB,oBAAoB,EAEpB,qBAAqB,EACrB,yBAAyB,EACzB,IAAI,EACL,MAAM,aAAa,CAAC;AAErB,qBAAa,eAAe;IACd,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,UAAU;IAE/C;;OAEG;IACG,MAAM,CAAC,MAAM,CAAC,EAAE,wBAAwB,GAAG,OAAO,CAAC,oBAAoB,CAAC,YAAY,CAAC,CAAC;IAK5F;;OAEG;IACG,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAK5C;;OAEG;IACG,MAAM,CAAC,IAAI,EAAE,yBAAyB,GAAG,OAAO,CAAC,YAAY,CAAC;IAKpE;;OAEG;IACG,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,yBAAyB,GAAG,OAAO,CAAC,YAAY,CAAC;IAKhF;;OAEG;IACG,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAK1C;;;OAGG;IACG,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,kBAAkB,GAAE,OAAe,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IAMhF;;OAEG;IACG,YAAY,CAAC,EAAE,EAAE,MAAM,EAAE,WAAW,GAAE,OAAc,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;IAMpF;;OAEG;IACG,mBAAmB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;IAKnE;;OAEG;IACG,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;IAKlD;;OAEG;IACG,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAKlE;;OAEG;IACG,WAAW,CAAC,EAAE,EAAE,MAAM,EAAE,WAAW,GAAE,OAAe,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;IAMpF;;OAEG;IACG,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,yBAAyB,CAAC;IAK9D;;OAEG;IACG,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;IAQjF;;OAEG;IACG,YAAY,CAAC,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAK/E"}
@@ -0,0 +1,124 @@
1
+ "use strict";
2
+ /**
3
+ * Organization API Client
4
+ *
5
+ * Handles organization data and hierarchy operations:
6
+ * - Search organizations
7
+ * - Get organization by ID
8
+ * - Create/Update/Delete
9
+ * - Hierarchy management (Ancestors, Descendants, Reporting Line)
10
+ */
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.OrganizationAPI = void 0;
13
+ class OrganizationAPI {
14
+ constructor(client) {
15
+ this.client = client;
16
+ }
17
+ /**
18
+ * Search organizations with pagination and filters
19
+ */
20
+ async search(params) {
21
+ const response = await this.client.post('/organizations/search', params || {});
22
+ return response.data;
23
+ }
24
+ /**
25
+ * Get organization by ID
26
+ */
27
+ async get(id) {
28
+ const response = await this.client.get(`/organizations/${id}`);
29
+ return response.data.data;
30
+ }
31
+ /**
32
+ * Create a new organization
33
+ */
34
+ async create(data) {
35
+ const response = await this.client.post('/organizations', data);
36
+ return response.data.data;
37
+ }
38
+ /**
39
+ * Update organization
40
+ */
41
+ async update(id, data) {
42
+ const response = await this.client.put(`/organizations/${id}`, data);
43
+ return response.data.data;
44
+ }
45
+ /**
46
+ * Delete organization
47
+ */
48
+ async delete(id) {
49
+ const response = await this.client.delete(`/organizations/${id}`);
50
+ return !!response.data.success;
51
+ }
52
+ /**
53
+ * Get organization users
54
+ * @param includeDescendants If true, returns users from all descendant organizations recursively
55
+ */
56
+ async getUsers(id, includeDescendants = false) {
57
+ const params = includeDescendants ? { includeDescendants: 'true' } : {};
58
+ const response = await this.client.get(`/organizations/${id}/users`, { params });
59
+ return response.data.data || [];
60
+ }
61
+ /**
62
+ * Get ancestors (parent organizations at all levels)
63
+ */
64
+ async getAncestors(id, includeRoot = true) {
65
+ const params = { includeRoot: String(includeRoot) };
66
+ const response = await this.client.get(`/organizations/${id}/ancestors`, { params });
67
+ return response.data.data || [];
68
+ }
69
+ /**
70
+ * Get immediate supervisor/parent organization
71
+ */
72
+ async getDirectSupervisor(id) {
73
+ const response = await this.client.get(`/organizations/${id}/supervisor`);
74
+ return response.data.data || null;
75
+ }
76
+ /**
77
+ * Get full path from root to organization
78
+ */
79
+ async getPath(id) {
80
+ const response = await this.client.get(`/organizations/${id}/path`);
81
+ return response.data.data || [];
82
+ }
83
+ /**
84
+ * Get reporting line (hierarchical and functional)
85
+ */
86
+ async getReportingLine(id) {
87
+ const response = await this.client.get(`/organizations/${id}/reporting-line`);
88
+ return response.data.data;
89
+ }
90
+ /**
91
+ * Get sibling organizations (same parent)
92
+ */
93
+ async getSiblings(id, includeSelf = false) {
94
+ const params = { includeSelf: String(includeSelf) };
95
+ const response = await this.client.get(`/organizations/${id}/siblings`, { params });
96
+ return response.data.data || [];
97
+ }
98
+ /**
99
+ * Get organization level
100
+ */
101
+ async getLevel(id) {
102
+ const response = await this.client.get(`/organizations/${id}/level`);
103
+ return response.data.data;
104
+ }
105
+ /**
106
+ * Get lowest common ancestor of two organizations
107
+ */
108
+ async getCommonAncestor(orgA, orgB) {
109
+ const params = { orgA, orgB };
110
+ const response = await this.client.get('/organizations/common-ancestor', {
111
+ params,
112
+ });
113
+ return response.data.data || null;
114
+ }
115
+ /**
116
+ * Check if an organization is an ancestor of another
117
+ */
118
+ async isAncestorOf(ancestorId, descendantId) {
119
+ const params = { ancestorId, descendantId };
120
+ const response = await this.client.get('/organizations/check-ancestor', { params });
121
+ return !!response.data.data;
122
+ }
123
+ }
124
+ exports.OrganizationAPI = OrganizationAPI;
@@ -1 +1 @@
1
- {"version":3,"file":"system-config.api.d.ts","sourceRoot":"","sources":["../../../src/client/api/system-config.api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,uBAAuB,EAAe,MAAM,aAAa,CAAC;AAE5H;;;;GAIG;AACH,qBAAa,eAAe;IACd,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,UAAU;IAEtC;;;OAGG;IACG,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAOtE;;;OAGG;IACG,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAK/E;;;OAGG;IACG,QAAQ,IAAI,OAAO,CAAC,sBAAsB,CAAC;IAIjD;;;OAGG;IACG,oBAAoB,IAAI,OAAO,CAAC,iBAAiB,CAAC;IAKxD;;;OAGG;IACG,oBAAoB,IAAI,OAAO,CAAC,uBAAuB,CAAC;CAS/D"}
1
+ {"version":3,"file":"system-config.api.d.ts","sourceRoot":"","sources":["../../../src/client/api/system-config.api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MA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;;;;OAOG;IACG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI3C;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACG,IAAI,CAAC,MAAM,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,oBAAoB,CAAC,gBAAgB,CAAC,CAAC;CAuBrF"}
@@ -153,9 +153,7 @@ class UserAPI {
153
153
  queryParams.page_size = params.page_size.toString();
154
154
  }
155
155
  if (params?.updated_after) {
156
- const updatedAfter = params.updated_after instanceof Date
157
- ? params.updated_after.toISOString()
158
- : params.updated_after;
156
+ const updatedAfter = params.updated_after instanceof Date ? params.updated_after.toISOString() : params.updated_after;
159
157
  queryParams.updated_after = updatedAfter;
160
158
  }
161
159
  const queryString = new URLSearchParams(queryParams).toString();
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Webhook Proxy API
3
+ *
4
+ * Handles webhook proxy operations for external applications:
5
+ * - Send webhook requests through proxy
6
+ * - Get webhook log status and details
7
+ *
8
+ * @requires API Key authentication
9
+ */
10
+ import { AuthClient } from '../auth-client';
11
+ import type { WebhookProxyRequest, WebhookProxyResponse, WebhookLogDetail } from '../../types/webhook.types';
12
+ export declare class WebhookAPI {
13
+ private client;
14
+ constructor(client: AuthClient);
15
+ /**
16
+ * ส่ง webhook request ผ่าน proxy endpoint
17
+ *
18
+ * @description
19
+ * - ส่ง webhook request ไปยัง external URL ผ่านระบบ proxy
20
+ * - ระบบจะสร้าง webhook_log และยิง webhook ออกไปให้
21
+ * - รองรับ retry mechanism อัตโนมัติ
22
+ * - ส่ง async: true เพื่อยิงทันทีและรับ result (http_status, response_body) ใน response
23
+ *
24
+ * @example
25
+ * ```typescript
26
+ * // ส่ง webhook request (โหมดปกติ - ได้ webhook_log_id กลับมา แล้วค่อย getStatus ตรวจสอบ)
27
+ * const result = await authClient.webhook.proxy({
28
+ * webhook_url: 'https://api.example.com/webhooks/users',
29
+ * event_type: 'user.created',
30
+ * payload: {
31
+ * data: { id: 'user-123', email: 'user@example.com' },
32
+ * object: 'event',
33
+ * type: 'user.created'
34
+ * },
35
+ * headers: { 'Authorization': 'Bearer token' },
36
+ * secret: 'webhook-secret',
37
+ * timeout_ms: 30000,
38
+ * max_retries: 3
39
+ * });
40
+ * console.log('Webhook Log ID:', result.webhook_log_id);
41
+ *
42
+ * // โหมด async: true - ยิงทันทีและได้ result กลับใน response (ไม่ต้อง getStatus)
43
+ * const resultAsync = await authClient.webhook.proxy({
44
+ * webhook_url: 'https://api.example.com/webhooks/users',
45
+ * event_type: 'user.created',
46
+ * payload: { data: { id: 'user-123' }, object: 'event', type: 'user.created' },
47
+ * async: true
48
+ * });
49
+ * if (resultAsync.status === 'success') {
50
+ * console.log('HTTP Status:', resultAsync.http_status);
51
+ * console.log('Response Body:', resultAsync.response_body);
52
+ * console.log('Execution Time:', resultAsync.execution_time_ms, 'ms');
53
+ * } else {
54
+ * console.error('Failed:', resultAsync.error_message);
55
+ * }
56
+ * ```
57
+ */
58
+ proxy(request: WebhookProxyRequest): Promise<WebhookProxyResponse>;
59
+ /**
60
+ * ดึง webhook log detail ตาม ID
61
+ *
62
+ * @description
63
+ * - ดึงข้อมูล webhook log ตาม ID ที่ส่งกลับมาจาก proxy()
64
+ * - แสดง status, response, error message, และข้อมูลอื่นๆ
65
+ * - สามารถดึงได้เฉพาะ webhook logs ของ application ที่ authenticate อยู่เท่านั้น
66
+ *
67
+ * @example
68
+ * ```typescript
69
+ * // ดึง webhook log detail
70
+ * const log = await authClient.webhook.getStatus('log-123e4567-e89b-12d3-a456-426614174000');
71
+ *
72
+ * console.log('Status:', log.status); // 'success', 'failed', 'pending', 'retrying'
73
+ * console.log('HTTP Status:', log.http_status); // 200, 404, 500, etc.
74
+ * console.log('Response Body:', log.response_body);
75
+ * console.log('Error:', log.error_message);
76
+ * console.log('Execution Time:', log.execution_time_ms, 'ms');
77
+ * console.log('Retry Count:', log.retry_count);
78
+ *
79
+ * // ตรวจสอบว่า webhook สำเร็จหรือไม่
80
+ * if (log.status === 'success') {
81
+ * console.log('Webhook delivered successfully!');
82
+ * } else if (log.status === 'failed') {
83
+ * console.error('Webhook failed:', log.error_message);
84
+ * }
85
+ * ```
86
+ */
87
+ getStatus(webhookLogId: string): Promise<WebhookLogDetail>;
88
+ }
89
+ //# sourceMappingURL=webhook.api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webhook.api.d.ts","sourceRoot":"","sources":["../../../src/client/api/webhook.api.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,OAAO,KAAK,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAE7G,qBAAa,UAAU;IACT,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,UAAU;IAEtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA0CG;IACG,KAAK,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAKxE;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACG,SAAS,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;CAIjE"}