win-portal-auth-sdk 1.6.0 → 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.
@@ -19,10 +19,11 @@ export declare class WebhookAPI {
19
19
  * - ส่ง webhook request ไปยัง external URL ผ่านระบบ proxy
20
20
  * - ระบบจะสร้าง webhook_log และยิง webhook ออกไปให้
21
21
  * - รองรับ retry mechanism อัตโนมัติ
22
+ * - ส่ง async: true เพื่อยิงทันทีและรับ result (http_status, response_body) ใน response
22
23
  *
23
24
  * @example
24
25
  * ```typescript
25
- * // ส่ง webhook request
26
+ * // ส่ง webhook request (โหมดปกติ - ได้ webhook_log_id กลับมา แล้วค่อย getStatus ตรวจสอบ)
26
27
  * const result = await authClient.webhook.proxy({
27
28
  * webhook_url: 'https://api.example.com/webhooks/users',
28
29
  * event_type: 'user.created',
@@ -31,21 +32,27 @@ export declare class WebhookAPI {
31
32
  * object: 'event',
32
33
  * type: 'user.created'
33
34
  * },
34
- * headers: {
35
- * 'Authorization': 'Bearer token'
36
- * },
35
+ * headers: { 'Authorization': 'Bearer token' },
37
36
  * secret: 'webhook-secret',
38
37
  * timeout_ms: 30000,
39
38
  * max_retries: 3
40
39
  * });
41
- *
42
40
  * console.log('Webhook Log ID:', result.webhook_log_id);
43
- * console.log('Status:', result.status);
44
41
  *
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);
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
+ * }
49
56
  * ```
50
57
  */
51
58
  proxy(request: WebhookProxyRequest): Promise<WebhookProxyResponse>;
@@ -1 +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"}
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"}
@@ -21,10 +21,11 @@ class WebhookAPI {
21
21
  * - ส่ง webhook request ไปยัง external URL ผ่านระบบ proxy
22
22
  * - ระบบจะสร้าง webhook_log และยิง webhook ออกไปให้
23
23
  * - รองรับ retry mechanism อัตโนมัติ
24
+ * - ส่ง async: true เพื่อยิงทันทีและรับ result (http_status, response_body) ใน response
24
25
  *
25
26
  * @example
26
27
  * ```typescript
27
- * // ส่ง webhook request
28
+ * // ส่ง webhook request (โหมดปกติ - ได้ webhook_log_id กลับมา แล้วค่อย getStatus ตรวจสอบ)
28
29
  * const result = await authClient.webhook.proxy({
29
30
  * webhook_url: 'https://api.example.com/webhooks/users',
30
31
  * event_type: 'user.created',
@@ -33,21 +34,27 @@ class WebhookAPI {
33
34
  * object: 'event',
34
35
  * type: 'user.created'
35
36
  * },
36
- * headers: {
37
- * 'Authorization': 'Bearer token'
38
- * },
37
+ * headers: { 'Authorization': 'Bearer token' },
39
38
  * secret: 'webhook-secret',
40
39
  * timeout_ms: 30000,
41
40
  * max_retries: 3
42
41
  * });
43
- *
44
42
  * console.log('Webhook Log ID:', result.webhook_log_id);
45
- * console.log('Status:', result.status);
46
43
  *
47
- * // ตรวจสอบ status
48
- * const log = await authClient.webhook.getStatus(result.webhook_log_id);
49
- * console.log('Final Status:', log.status);
50
- * console.log('HTTP Status:', log.http_status);
44
+ * // โหมด async: true - ยิงทันทีและได้ result กลับใน response (ไม่ต้อง getStatus)
45
+ * const resultAsync = await authClient.webhook.proxy({
46
+ * webhook_url: 'https://api.example.com/webhooks/users',
47
+ * event_type: 'user.created',
48
+ * payload: { data: { id: 'user-123' }, object: 'event', type: 'user.created' },
49
+ * async: true
50
+ * });
51
+ * if (resultAsync.status === 'success') {
52
+ * console.log('HTTP Status:', resultAsync.http_status);
53
+ * console.log('Response Body:', resultAsync.response_body);
54
+ * console.log('Execution Time:', resultAsync.execution_time_ms, 'ms');
55
+ * } else {
56
+ * console.error('Failed:', resultAsync.error_message);
57
+ * }
51
58
  * ```
52
59
  */
53
60
  async proxy(request) {
@@ -22,10 +22,13 @@ export interface WebhookProxyRequest {
22
22
  timeout_ms?: number;
23
23
  /** จำนวนครั้งสูงสุดที่จะ retry */
24
24
  max_retries?: number;
25
+ /** ถ้า true = ยิงทันทีและส่ง result (http_status, response_body) กลับใน response */
26
+ async?: boolean;
25
27
  }
26
28
  /**
27
29
  * Webhook Proxy Response
28
30
  * Response หลังจากส่ง webhook request
31
+ * เมื่อส่ง async: true จะมี http_status, response_body, execution_time_ms (และ error_message ถ้าล้มเหลว)
29
32
  */
30
33
  export interface WebhookProxyResponse {
31
34
  /** รหัส webhook log ที่สร้างขึ้น */
@@ -34,6 +37,14 @@ export interface WebhookProxyResponse {
34
37
  status: 'pending' | 'success' | 'failed' | 'retrying';
35
38
  /** ข้อความอธิบาย */
36
39
  message: string;
40
+ /** HTTP status จากปลายทาง (เมื่อ async=true) */
41
+ http_status?: number;
42
+ /** Response body จากปลายทาง (เมื่อ async=true) */
43
+ response_body?: unknown;
44
+ /** เวลาที่ใช้ส่ง request มิลลิวินาที (เมื่อ async=true) */
45
+ execution_time_ms?: number;
46
+ /** ข้อความ error (เมื่อ async=true และล้มเหลว) */
47
+ error_message?: string;
37
48
  }
38
49
  /**
39
50
  * Webhook Log Detail
@@ -1 +1 @@
1
- {"version":3,"file":"webhook.types.d.ts","sourceRoot":"","sources":["../../src/types/webhook.types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC,qCAAqC;IACrC,WAAW,EAAE,MAAM,CAAC;IAEpB,sBAAsB;IACtB,UAAU,EAAE,MAAM,CAAC;IAEnB,yBAAyB;IACzB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAE7B,yCAAyC;IACzC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,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,CAAC;IAE1B,yBAAyB;IACzB,UAAU,EAAE,IAAI,GAAG,MAAM,CAAC;CAC3B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "win-portal-auth-sdk",
3
- "version": "1.6.0",
3
+ "version": "1.6.1",
4
4
  "description": "Shared authentication SDK for Win Portal applications with JWT and OAuth support",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",