win-portal-auth-sdk 1.5.6 → 1.6.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.
Files changed (41) 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 +1 -1
  4. package/dist/client/api/email.api.d.ts.map +1 -1
  5. package/dist/client/api/index.d.ts +4 -0
  6. package/dist/client/api/index.d.ts.map +1 -1
  7. package/dist/client/api/index.js +7 -1
  8. package/dist/client/api/organization.api.d.ts +73 -0
  9. package/dist/client/api/organization.api.d.ts.map +1 -0
  10. package/dist/client/api/organization.api.js +124 -0
  11. package/dist/client/api/system-config.api.d.ts.map +1 -1
  12. package/dist/client/api/user.api.d.ts +30 -1
  13. package/dist/client/api/user.api.d.ts.map +1 -1
  14. package/dist/client/api/user.api.js +45 -0
  15. package/dist/client/api/webhook.api.d.ts +82 -0
  16. package/dist/client/api/webhook.api.d.ts.map +1 -0
  17. package/dist/client/api/webhook.api.js +90 -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 +17 -94
  25. package/dist/types/email.types.d.ts.map +1 -1
  26. package/dist/types/email.types.js +0 -1
  27. package/dist/types/index.d.ts +4 -0
  28. package/dist/types/index.d.ts.map +1 -1
  29. package/dist/types/index.js +8 -0
  30. package/dist/types/organization.types.d.ts +104 -0
  31. package/dist/types/organization.types.d.ts.map +1 -0
  32. package/dist/types/organization.types.js +19 -0
  33. package/dist/types/user.types.d.ts +47 -0
  34. package/dist/types/user.types.d.ts.map +1 -1
  35. package/dist/types/webhook.types.d.ts +82 -0
  36. package/dist/types/webhook.types.d.ts.map +1 -0
  37. package/dist/types/webhook.types.js +7 -0
  38. package/dist/types/workflow.types.d.ts +234 -0
  39. package/dist/types/workflow.types.d.ts.map +1 -0
  40. package/dist/types/workflow.types.js +7 -0
  41. 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,CAA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;IACG,eAAe,CACnB,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,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 type { SendEmailRequest, SendEmailResponse } from '../../types/email.types';
12
+ import { SendEmailRequest, SendEmailResponse } from '../../types';
13
13
  /**
14
14
  * Email API
15
15
  *
@@ -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;AAE5C,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAEnF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,qBAAa,QAAQ;IACP,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,UAAU;IAEtC;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACG,SAAS,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAKtE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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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Response, 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,MA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AAC;AACtG,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,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,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EACL,YAAY,EACZ,sBAAsB,EACtB,iBAAiB,EACjB,uBAAuB,EAExB,MAAM,aAAa,CAAC;AAErB;;;;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"}
@@ -9,7 +9,7 @@
9
9
  * - Delete user
10
10
  */
11
11
  import { AuthClient } from '../auth-client';
12
- import { User, CreateUserRequest, UpdateUserRequest, UserSearchParams, ApiPaginatedResponse } from '../../types';
12
+ import { User, CreateUserRequest, UpdateUserRequest, UserSearchParams, UserSyncResponse, UserSyncParams, ApiPaginatedResponse } from '../../types';
13
13
  export declare class UserAPI {
14
14
  private readonly client;
15
15
  constructor(client: AuthClient);
@@ -100,5 +100,34 @@ export declare class UserAPI {
100
100
  * ```
101
101
  */
102
102
  delete(userId: string): Promise<void>;
103
+ /**
104
+ * Sync users for external applications
105
+ *
106
+ * @description ดึงข้อมูลผู้ใช้แบบ paginated สำหรับ sync operations
107
+ * ใช้สำหรับ external applications ที่ต้องการ sync user data
108
+ * ต้องใช้ API Key authentication
109
+ *
110
+ * @example
111
+ * ```typescript
112
+ * // Sync all users (first page)
113
+ * const result = await authClient.user.sync({
114
+ * page: 1,
115
+ * page_size: 100
116
+ * });
117
+ *
118
+ * // Sync users updated after specific date
119
+ * const updatedUsers = await authClient.user.sync({
120
+ * page: 1,
121
+ * page_size: 100,
122
+ * updated_after: new Date('2024-01-01')
123
+ * });
124
+ *
125
+ * // Access paginated data
126
+ * console.log(result.data); // UserSyncResponse[]
127
+ * console.log(result.pagination.total); // Total count
128
+ * console.log(result.pagination.has_next); // Has next page
129
+ * ```
130
+ */
131
+ sync(params?: UserSyncParams): Promise<ApiPaginatedResponse<UserSyncResponse>>;
103
132
  }
104
133
  //# sourceMappingURL=user.api.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"user.api.d.ts","sourceRoot":"","sources":["../../../src/client/api/user.api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EACL,IAAI,EACJ,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,oBAAoB,EAErB,MAAM,aAAa,CAAC;AAErB,qBAAa,OAAO;IACN,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,UAAU;IAE/C;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACG,MAAM,CAAC,MAAM,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC;IAK5E;;;;;;;OAOG;IACG,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAKxC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;IACG,MAAM,CAAC,QAAQ,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAKxD;;;;;;;;;;;;OAYG;IACG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAKxE;;;;;;;OAOG;IACG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAG5C"}
1
+ {"version":3,"file":"user.api.d.ts","sourceRoot":"","sources":["../../../src/client/api/user.api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EACL,IAAI,EACJ,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,oBAAoB,EAErB,MAAM,aAAa,CAAC;AAErB,qBAAa,OAAO;IACN,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,UAAU;IAE/C;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACG,MAAM,CAAC,MAAM,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC;IAK5E;;;;;;;OAOG;IACG,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAKxC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;IACG,MAAM,CAAC,QAAQ,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAKxD;;;;;;;;;;;;OAYG;IACG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAKxE;;;;;;;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"}
@@ -116,5 +116,50 @@ class UserAPI {
116
116
  async delete(userId) {
117
117
  await this.client.delete(`/users/${userId}`);
118
118
  }
119
+ /**
120
+ * Sync users for external applications
121
+ *
122
+ * @description ดึงข้อมูลผู้ใช้แบบ paginated สำหรับ sync operations
123
+ * ใช้สำหรับ external applications ที่ต้องการ sync user data
124
+ * ต้องใช้ API Key authentication
125
+ *
126
+ * @example
127
+ * ```typescript
128
+ * // Sync all users (first page)
129
+ * const result = await authClient.user.sync({
130
+ * page: 1,
131
+ * page_size: 100
132
+ * });
133
+ *
134
+ * // Sync users updated after specific date
135
+ * const updatedUsers = await authClient.user.sync({
136
+ * page: 1,
137
+ * page_size: 100,
138
+ * updated_after: new Date('2024-01-01')
139
+ * });
140
+ *
141
+ * // Access paginated data
142
+ * console.log(result.data); // UserSyncResponse[]
143
+ * console.log(result.pagination.total); // Total count
144
+ * console.log(result.pagination.has_next); // Has next page
145
+ * ```
146
+ */
147
+ async sync(params) {
148
+ const queryParams = {};
149
+ if (params?.page !== undefined) {
150
+ queryParams.page = params.page.toString();
151
+ }
152
+ if (params?.page_size !== undefined) {
153
+ queryParams.page_size = params.page_size.toString();
154
+ }
155
+ if (params?.updated_after) {
156
+ const updatedAfter = params.updated_after instanceof Date ? params.updated_after.toISOString() : params.updated_after;
157
+ queryParams.updated_after = updatedAfter;
158
+ }
159
+ const queryString = new URLSearchParams(queryParams).toString();
160
+ const url = `/users/sync${queryString ? `?${queryString}` : ''}`;
161
+ const response = await this.client.get(url);
162
+ return response.data;
163
+ }
119
164
  }
120
165
  exports.UserAPI = UserAPI;
@@ -0,0 +1,82 @@
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
+ *
23
+ * @example
24
+ * ```typescript
25
+ * // ส่ง webhook request
26
+ * const result = await authClient.webhook.proxy({
27
+ * webhook_url: 'https://api.example.com/webhooks/users',
28
+ * event_type: 'user.created',
29
+ * payload: {
30
+ * data: { id: 'user-123', email: 'user@example.com' },
31
+ * object: 'event',
32
+ * type: 'user.created'
33
+ * },
34
+ * headers: {
35
+ * 'Authorization': 'Bearer token'
36
+ * },
37
+ * secret: 'webhook-secret',
38
+ * timeout_ms: 30000,
39
+ * max_retries: 3
40
+ * });
41
+ *
42
+ * console.log('Webhook Log ID:', result.webhook_log_id);
43
+ * console.log('Status:', result.status);
44
+ *
45
+ * // ตรวจสอบ status
46
+ * const log = await authClient.webhook.getStatus(result.webhook_log_id);
47
+ * console.log('Final Status:', log.status);
48
+ * console.log('HTTP Status:', log.http_status);
49
+ * ```
50
+ */
51
+ proxy(request: WebhookProxyRequest): Promise<WebhookProxyResponse>;
52
+ /**
53
+ * ดึง webhook log detail ตาม ID
54
+ *
55
+ * @description
56
+ * - ดึงข้อมูล webhook log ตาม ID ที่ส่งกลับมาจาก proxy()
57
+ * - แสดง status, response, error message, และข้อมูลอื่นๆ
58
+ * - สามารถดึงได้เฉพาะ webhook logs ของ application ที่ authenticate อยู่เท่านั้น
59
+ *
60
+ * @example
61
+ * ```typescript
62
+ * // ดึง webhook log detail
63
+ * const log = await authClient.webhook.getStatus('log-123e4567-e89b-12d3-a456-426614174000');
64
+ *
65
+ * console.log('Status:', log.status); // 'success', 'failed', 'pending', 'retrying'
66
+ * console.log('HTTP Status:', log.http_status); // 200, 404, 500, etc.
67
+ * console.log('Response Body:', log.response_body);
68
+ * console.log('Error:', log.error_message);
69
+ * console.log('Execution Time:', log.execution_time_ms, 'ms');
70
+ * console.log('Retry Count:', log.retry_count);
71
+ *
72
+ * // ตรวจสอบว่า webhook สำเร็จหรือไม่
73
+ * if (log.status === 'success') {
74
+ * console.log('Webhook delivered successfully!');
75
+ * } else if (log.status === 'failed') {
76
+ * console.error('Webhook failed:', log.error_message);
77
+ * }
78
+ * ```
79
+ */
80
+ getStatus(webhookLogId: string): Promise<WebhookLogDetail>;
81
+ }
82
+ //# 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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAmCG;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"}