win-portal-auth-sdk 1.5.5 → 1.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +57 -7
- package/dist/client/api/email.api.d.ts +174 -0
- package/dist/client/api/email.api.d.ts.map +1 -0
- package/dist/client/api/email.api.js +181 -0
- package/dist/client/api/index.d.ts +3 -0
- package/dist/client/api/index.d.ts.map +1 -1
- package/dist/client/api/index.js +5 -1
- package/dist/client/api/otp.api.d.ts +87 -0
- package/dist/client/api/otp.api.d.ts.map +1 -0
- package/dist/client/api/otp.api.js +65 -0
- package/dist/client/api/user.api.d.ts +15 -0
- package/dist/client/api/user.api.d.ts.map +1 -1
- package/dist/client/api/user.api.js +15 -0
- package/dist/client/auth-client.d.ts +3 -1
- package/dist/client/auth-client.d.ts.map +1 -1
- package/dist/client/auth-client.js +3 -3
- package/dist/types/email.types.d.ts +243 -0
- package/dist/types/email.types.d.ts.map +1 -0
- package/dist/types/email.types.js +8 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +2 -0
- package/dist/types/user.types.d.ts +4 -1
- package/dist/types/user.types.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -152,6 +152,36 @@ await authClient.line.sendNotification({
|
|
|
152
152
|
action_url: 'https://app.example.com/tasks/123',
|
|
153
153
|
priority: 'high',
|
|
154
154
|
});
|
|
155
|
+
|
|
156
|
+
// OTP Service (for external applications)
|
|
157
|
+
// Send OTP via SMS
|
|
158
|
+
const otpResult = await authClient.otp.sendOTP({
|
|
159
|
+
method: 'sms',
|
|
160
|
+
recipient: '0812345678',
|
|
161
|
+
context: 'login',
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
console.log('OTP ID:', otpResult.otp_id); // UUID for verification
|
|
165
|
+
console.log('Ref Code:', otpResult.ref_code); // OTP-XXXXXX (for tracking/billing)
|
|
166
|
+
console.log('Expires at:', otpResult.expires_at);
|
|
167
|
+
console.log('Masked recipient:', otpResult.masked_recipient);
|
|
168
|
+
|
|
169
|
+
// Send OTP via Email
|
|
170
|
+
const emailOtpResult = await authClient.otp.sendOTP({
|
|
171
|
+
method: 'email',
|
|
172
|
+
recipient: 'user@example.com',
|
|
173
|
+
context: 'verification',
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
// Verify OTP
|
|
177
|
+
const verifyResult = await authClient.otp.verifyOTP({
|
|
178
|
+
otp_id: otpResult.otp_id,
|
|
179
|
+
code: '123456', // OTP code from user
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
if (verifyResult.verified) {
|
|
183
|
+
console.log('OTP verified successfully');
|
|
184
|
+
}
|
|
155
185
|
```
|
|
156
186
|
|
|
157
187
|
**For custom endpoints, use direct HTTP methods:**
|
|
@@ -320,9 +350,9 @@ const client = new AuthClient({
|
|
|
320
350
|
apiKey: 'your-api-key',
|
|
321
351
|
baseURL: 'https://api.example.com',
|
|
322
352
|
advanced: {
|
|
323
|
-
activityThrottleMs: 500,
|
|
324
|
-
refreshTimeoutMs: 10000,
|
|
325
|
-
}
|
|
353
|
+
activityThrottleMs: 500, // ลด throttle time สำหรับ responsive มากขึ้น (แต่ใช้ CPU มากขึ้น)
|
|
354
|
+
refreshTimeoutMs: 10000, // เพิ่ม timeout สำหรับ slow network
|
|
355
|
+
},
|
|
326
356
|
});
|
|
327
357
|
```
|
|
328
358
|
|
|
@@ -374,6 +404,26 @@ const client = new AuthClient({
|
|
|
374
404
|
- Automatically uses application from API key context
|
|
375
405
|
- No need to provide application code or ID
|
|
376
406
|
|
|
407
|
+
**OTP Service (for external applications):**
|
|
408
|
+
|
|
409
|
+
- `otp.sendOTP({ method, recipient, context?, metadata? })` - Send OTP via SMS or Email
|
|
410
|
+
- `method`: `'sms'` | `'email'` - Delivery method
|
|
411
|
+
- `recipient`: Phone number or email address
|
|
412
|
+
- `context`: Optional context (e.g., 'login', 'verification')
|
|
413
|
+
- `metadata`: Optional JSON string for additional data
|
|
414
|
+
- Returns: `{ otp_id, ref_code, expires_at, masked_recipient }`
|
|
415
|
+
- `otp_id`: UUID for verification
|
|
416
|
+
- `ref_code`: Short reference code (OTP-XXXXXX) for tracking/billing
|
|
417
|
+
- `expires_at`: OTP expiration timestamp
|
|
418
|
+
- `masked_recipient`: Masked phone number or email
|
|
419
|
+
- Requires API Key authentication
|
|
420
|
+
|
|
421
|
+
- `otp.verifyOTP({ otp_id, code })` - Verify OTP code
|
|
422
|
+
- `otp_id`: OTP ID from sendOTP response
|
|
423
|
+
- `code`: 6-digit OTP code
|
|
424
|
+
- Returns: `{ verified: boolean }`
|
|
425
|
+
- Requires API Key authentication
|
|
426
|
+
|
|
377
427
|
#### Utility Methods
|
|
378
428
|
|
|
379
429
|
- `setToken(token, type?)` - Set authentication token
|
|
@@ -410,11 +460,11 @@ await authClient.enableInactivityDetection({
|
|
|
410
460
|
// Redirect to login หรือ logout
|
|
411
461
|
authClient.clearToken();
|
|
412
462
|
window.location.href = '/login';
|
|
413
|
-
}
|
|
463
|
+
},
|
|
414
464
|
},
|
|
415
465
|
timeoutSeconds: 1800, // 30 minutes (optional, default: จาก session management config)
|
|
416
466
|
warningSeconds: 300, // 5 minutes warning (optional, default: จาก session management config)
|
|
417
|
-
events: ['mousemove', 'keydown', 'touchstart', 'scroll'] // (optional, default: ทั้งหมด)
|
|
467
|
+
events: ['mousemove', 'keydown', 'touchstart', 'scroll'], // (optional, default: ทั้งหมด)
|
|
418
468
|
});
|
|
419
469
|
|
|
420
470
|
// Disable inactivity detection
|
|
@@ -437,9 +487,9 @@ await authClient.enableSessionExpirationMonitoring({
|
|
|
437
487
|
onSessionExpired: () => {
|
|
438
488
|
console.log('Session expired');
|
|
439
489
|
// Redirect to login
|
|
440
|
-
}
|
|
490
|
+
},
|
|
441
491
|
},
|
|
442
|
-
checkIntervalSeconds: 30 // ตรวจสอบทุก 30 วินาที
|
|
492
|
+
checkIntervalSeconds: 30, // ตรวจสอบทุก 30 วินาที
|
|
443
493
|
});
|
|
444
494
|
```
|
|
445
495
|
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Email Service API
|
|
3
|
+
*
|
|
4
|
+
* Handles email operations for external applications:
|
|
5
|
+
* - Send email with template (Template Mode)
|
|
6
|
+
* - Send email with raw HTML (Raw HTML Mode)
|
|
7
|
+
* - Support CC, BCC, and attachments
|
|
8
|
+
*
|
|
9
|
+
* @requires API Key authentication
|
|
10
|
+
*/
|
|
11
|
+
import { AuthClient } from '../auth-client';
|
|
12
|
+
import type { SendEmailRequest, SendEmailResponse } from '../../types/email.types';
|
|
13
|
+
/**
|
|
14
|
+
* Email API
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* // Template Mode
|
|
19
|
+
* const result = await authClient.email.sendEmail({
|
|
20
|
+
* template_code: 'welcome_email',
|
|
21
|
+
* template_data: {
|
|
22
|
+
* userName: 'สมชาย ใจดี',
|
|
23
|
+
* activationLink: 'https://app.com/activate?token=xxx'
|
|
24
|
+
* },
|
|
25
|
+
* recipient_email: 'user@example.com',
|
|
26
|
+
* recipient_name: 'สมชาย ใจดี',
|
|
27
|
+
* language: 'th',
|
|
28
|
+
* cc: ['manager@example.com'],
|
|
29
|
+
* attachments: [
|
|
30
|
+
* {
|
|
31
|
+
* filename: 'welcome.pdf',
|
|
32
|
+
* href: 'https://api.example.com/files/123e4567-e89b-12d3-a456-426614174000/content' // URL จาก File API
|
|
33
|
+
* }
|
|
34
|
+
* ]
|
|
35
|
+
* });
|
|
36
|
+
*
|
|
37
|
+
* // Raw HTML Mode
|
|
38
|
+
* const result = await authClient.email.sendEmail({
|
|
39
|
+
* html_body: '<h1>ยินดีต้อนรับ</h1><p>ขอบคุณที่สมัครสมาชิก</p>',
|
|
40
|
+
* subject: 'ยินดีต้อนรับสู่ระบบ',
|
|
41
|
+
* recipient_email: 'user@example.com',
|
|
42
|
+
* recipient_name: 'สมชาย ใจดี',
|
|
43
|
+
* text_body: 'ยินดีต้อนรับ ขอบคุณที่สมัครสมาชิก',
|
|
44
|
+
* cc: ['manager@example.com'],
|
|
45
|
+
* bcc: ['archive@example.com']
|
|
46
|
+
* });
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export declare class EmailAPI {
|
|
50
|
+
private client;
|
|
51
|
+
constructor(client: AuthClient);
|
|
52
|
+
/**
|
|
53
|
+
* Send email (auto-detect Template Mode or Raw HTML Mode)
|
|
54
|
+
*
|
|
55
|
+
* @param request - SendEmailRequest
|
|
56
|
+
* @returns SendEmailResponse
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```typescript
|
|
60
|
+
* // Template Mode
|
|
61
|
+
* const result = await authClient.email.sendEmail({
|
|
62
|
+
* template_code: 'welcome_email',
|
|
63
|
+
* template_data: { userName: 'John' },
|
|
64
|
+
* recipient_email: 'user@example.com'
|
|
65
|
+
* });
|
|
66
|
+
*
|
|
67
|
+
* // Raw HTML Mode
|
|
68
|
+
* const result = await authClient.email.sendEmail({
|
|
69
|
+
* html_body: '<h1>Hello</h1>',
|
|
70
|
+
* subject: 'Welcome',
|
|
71
|
+
* recipient_email: 'user@example.com'
|
|
72
|
+
* });
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
sendEmail(request: SendEmailRequest): Promise<SendEmailResponse>;
|
|
76
|
+
/**
|
|
77
|
+
* Send email with template (Template Mode - convenience method)
|
|
78
|
+
*
|
|
79
|
+
* @param templateCode - Template code from database
|
|
80
|
+
* @param templateData - Template data for rendering
|
|
81
|
+
* @param recipient - Email address or user ID
|
|
82
|
+
* @param options - Additional options (cc, bcc, attachments, etc.)
|
|
83
|
+
* @returns SendEmailResponse
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```typescript
|
|
87
|
+
* const result = await authClient.email.sendEmailWithTemplate(
|
|
88
|
+
* 'welcome_email',
|
|
89
|
+
* {
|
|
90
|
+
* userName: 'สมชาย ใจดี',
|
|
91
|
+
* activationLink: 'https://app.com/activate?token=xxx'
|
|
92
|
+
* },
|
|
93
|
+
* 'user@example.com',
|
|
94
|
+
* {
|
|
95
|
+
* recipient_name: 'สมชาย ใจดี',
|
|
96
|
+
* language: 'th',
|
|
97
|
+
* cc: ['manager@example.com'],
|
|
98
|
+
* attachments: [
|
|
99
|
+
* {
|
|
100
|
+
* filename: 'welcome.pdf',
|
|
101
|
+
* href: 'https://storage.azure.com/container/welcome.pdf' // URL จาก cloud storage
|
|
102
|
+
* }
|
|
103
|
+
* ]
|
|
104
|
+
* }
|
|
105
|
+
* );
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
sendEmailWithTemplate(templateCode: string, templateData: Record<string, any>, recipient: string, options?: {
|
|
109
|
+
recipient_name?: string;
|
|
110
|
+
recipient_id?: string;
|
|
111
|
+
language?: 'th' | 'en';
|
|
112
|
+
subject?: string;
|
|
113
|
+
cc?: string | string[];
|
|
114
|
+
bcc?: string | string[];
|
|
115
|
+
attachments?: Array<{
|
|
116
|
+
filename: string;
|
|
117
|
+
href: string;
|
|
118
|
+
content_type?: string;
|
|
119
|
+
}>;
|
|
120
|
+
priority?: 'low' | 'normal' | 'high' | 'urgent';
|
|
121
|
+
scheduled_at?: Date | string;
|
|
122
|
+
source?: string;
|
|
123
|
+
related_entity_id?: string;
|
|
124
|
+
related_entity_type?: string;
|
|
125
|
+
}): Promise<SendEmailResponse>;
|
|
126
|
+
/**
|
|
127
|
+
* Send email with raw HTML (Raw HTML Mode - convenience method)
|
|
128
|
+
*
|
|
129
|
+
* @param htmlBody - HTML content
|
|
130
|
+
* @param subject - Email subject
|
|
131
|
+
* @param recipient - Email address or user ID
|
|
132
|
+
* @param options - Additional options (text_body, cc, bcc, attachments, etc.)
|
|
133
|
+
* @returns SendEmailResponse
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
* ```typescript
|
|
137
|
+
* const result = await authClient.email.sendRawEmail(
|
|
138
|
+
* '<h1>ยินดีต้อนรับ</h1><p>ขอบคุณที่สมัครสมาชิก</p>',
|
|
139
|
+
* 'ยินดีต้อนรับสู่ระบบ',
|
|
140
|
+
* 'user@example.com',
|
|
141
|
+
* {
|
|
142
|
+
* recipient_name: 'สมชาย ใจดี',
|
|
143
|
+
* text_body: 'ยินดีต้อนรับ ขอบคุณที่สมัครสมาชิก',
|
|
144
|
+
* cc: ['manager@example.com'],
|
|
145
|
+
* bcc: ['archive@example.com'],
|
|
146
|
+
* attachments: [
|
|
147
|
+
* {
|
|
148
|
+
* filename: 'document.pdf',
|
|
149
|
+
* href: 'https://api.example.com/files/123e4567-e89b-12d3-a456-426614174000/content' // URL จาก File API
|
|
150
|
+
* }
|
|
151
|
+
* ]
|
|
152
|
+
* }
|
|
153
|
+
* );
|
|
154
|
+
* ```
|
|
155
|
+
*/
|
|
156
|
+
sendRawEmail(htmlBody: string, subject: string, recipient: string, options?: {
|
|
157
|
+
recipient_name?: string;
|
|
158
|
+
recipient_id?: string;
|
|
159
|
+
text_body?: string;
|
|
160
|
+
cc?: string | string[];
|
|
161
|
+
bcc?: string | string[];
|
|
162
|
+
attachments?: Array<{
|
|
163
|
+
filename: string;
|
|
164
|
+
href: string;
|
|
165
|
+
content_type?: string;
|
|
166
|
+
}>;
|
|
167
|
+
priority?: 'low' | 'normal' | 'high' | 'urgent';
|
|
168
|
+
scheduled_at?: Date | string;
|
|
169
|
+
source?: string;
|
|
170
|
+
related_entity_id?: string;
|
|
171
|
+
related_entity_type?: string;
|
|
172
|
+
}): Promise<SendEmailResponse>;
|
|
173
|
+
}
|
|
174
|
+
//# sourceMappingURL=email.api.d.ts.map
|
|
@@ -0,0 +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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AAQ,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"}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Email Service API
|
|
4
|
+
*
|
|
5
|
+
* Handles email operations for external applications:
|
|
6
|
+
* - Send email with template (Template Mode)
|
|
7
|
+
* - Send email with raw HTML (Raw HTML Mode)
|
|
8
|
+
* - Support CC, BCC, and attachments
|
|
9
|
+
*
|
|
10
|
+
* @requires API Key authentication
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.EmailAPI = void 0;
|
|
14
|
+
/**
|
|
15
|
+
* Email API
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* // Template Mode
|
|
20
|
+
* const result = await authClient.email.sendEmail({
|
|
21
|
+
* template_code: 'welcome_email',
|
|
22
|
+
* template_data: {
|
|
23
|
+
* userName: 'สมชาย ใจดี',
|
|
24
|
+
* activationLink: 'https://app.com/activate?token=xxx'
|
|
25
|
+
* },
|
|
26
|
+
* recipient_email: 'user@example.com',
|
|
27
|
+
* recipient_name: 'สมชาย ใจดี',
|
|
28
|
+
* language: 'th',
|
|
29
|
+
* cc: ['manager@example.com'],
|
|
30
|
+
* attachments: [
|
|
31
|
+
* {
|
|
32
|
+
* filename: 'welcome.pdf',
|
|
33
|
+
* href: 'https://api.example.com/files/123e4567-e89b-12d3-a456-426614174000/content' // URL จาก File API
|
|
34
|
+
* }
|
|
35
|
+
* ]
|
|
36
|
+
* });
|
|
37
|
+
*
|
|
38
|
+
* // Raw HTML Mode
|
|
39
|
+
* const result = await authClient.email.sendEmail({
|
|
40
|
+
* html_body: '<h1>ยินดีต้อนรับ</h1><p>ขอบคุณที่สมัครสมาชิก</p>',
|
|
41
|
+
* subject: 'ยินดีต้อนรับสู่ระบบ',
|
|
42
|
+
* recipient_email: 'user@example.com',
|
|
43
|
+
* recipient_name: 'สมชาย ใจดี',
|
|
44
|
+
* text_body: 'ยินดีต้อนรับ ขอบคุณที่สมัครสมาชิก',
|
|
45
|
+
* cc: ['manager@example.com'],
|
|
46
|
+
* bcc: ['archive@example.com']
|
|
47
|
+
* });
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
class EmailAPI {
|
|
51
|
+
constructor(client) {
|
|
52
|
+
this.client = client;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Send email (auto-detect Template Mode or Raw HTML Mode)
|
|
56
|
+
*
|
|
57
|
+
* @param request - SendEmailRequest
|
|
58
|
+
* @returns SendEmailResponse
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```typescript
|
|
62
|
+
* // Template Mode
|
|
63
|
+
* const result = await authClient.email.sendEmail({
|
|
64
|
+
* template_code: 'welcome_email',
|
|
65
|
+
* template_data: { userName: 'John' },
|
|
66
|
+
* recipient_email: 'user@example.com'
|
|
67
|
+
* });
|
|
68
|
+
*
|
|
69
|
+
* // Raw HTML Mode
|
|
70
|
+
* const result = await authClient.email.sendEmail({
|
|
71
|
+
* html_body: '<h1>Hello</h1>',
|
|
72
|
+
* subject: 'Welcome',
|
|
73
|
+
* recipient_email: 'user@example.com'
|
|
74
|
+
* });
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
async sendEmail(request) {
|
|
78
|
+
const response = await this.client.post('/api/v1/email/send', request);
|
|
79
|
+
return response.data.data;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Send email with template (Template Mode - convenience method)
|
|
83
|
+
*
|
|
84
|
+
* @param templateCode - Template code from database
|
|
85
|
+
* @param templateData - Template data for rendering
|
|
86
|
+
* @param recipient - Email address or user ID
|
|
87
|
+
* @param options - Additional options (cc, bcc, attachments, etc.)
|
|
88
|
+
* @returns SendEmailResponse
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```typescript
|
|
92
|
+
* const result = await authClient.email.sendEmailWithTemplate(
|
|
93
|
+
* 'welcome_email',
|
|
94
|
+
* {
|
|
95
|
+
* userName: 'สมชาย ใจดี',
|
|
96
|
+
* activationLink: 'https://app.com/activate?token=xxx'
|
|
97
|
+
* },
|
|
98
|
+
* 'user@example.com',
|
|
99
|
+
* {
|
|
100
|
+
* recipient_name: 'สมชาย ใจดี',
|
|
101
|
+
* language: 'th',
|
|
102
|
+
* cc: ['manager@example.com'],
|
|
103
|
+
* attachments: [
|
|
104
|
+
* {
|
|
105
|
+
* filename: 'welcome.pdf',
|
|
106
|
+
* href: 'https://storage.azure.com/container/welcome.pdf' // URL จาก cloud storage
|
|
107
|
+
* }
|
|
108
|
+
* ]
|
|
109
|
+
* }
|
|
110
|
+
* );
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
113
|
+
async sendEmailWithTemplate(templateCode, templateData, recipient, options) {
|
|
114
|
+
const request = {
|
|
115
|
+
template_code: templateCode,
|
|
116
|
+
template_data: templateData,
|
|
117
|
+
...(options?.language && { language: options.language }),
|
|
118
|
+
...(options?.subject && { subject: options.subject }),
|
|
119
|
+
...(recipient.includes('@') ? { recipient_email: recipient } : { recipient_id: recipient }),
|
|
120
|
+
...(options?.recipient_name && { recipient_name: options.recipient_name }),
|
|
121
|
+
...(options?.cc && { cc: options.cc }),
|
|
122
|
+
...(options?.bcc && { bcc: options.bcc }),
|
|
123
|
+
...(options?.attachments && { attachments: options.attachments }),
|
|
124
|
+
...(options?.priority && { priority: options.priority }),
|
|
125
|
+
...(options?.scheduled_at && { scheduled_at: options.scheduled_at }),
|
|
126
|
+
...(options?.source && { source: options.source }),
|
|
127
|
+
...(options?.related_entity_id && { related_entity_id: options.related_entity_id }),
|
|
128
|
+
...(options?.related_entity_type && { related_entity_type: options.related_entity_type }),
|
|
129
|
+
};
|
|
130
|
+
return this.sendEmail(request);
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Send email with raw HTML (Raw HTML Mode - convenience method)
|
|
134
|
+
*
|
|
135
|
+
* @param htmlBody - HTML content
|
|
136
|
+
* @param subject - Email subject
|
|
137
|
+
* @param recipient - Email address or user ID
|
|
138
|
+
* @param options - Additional options (text_body, cc, bcc, attachments, etc.)
|
|
139
|
+
* @returns SendEmailResponse
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* ```typescript
|
|
143
|
+
* const result = await authClient.email.sendRawEmail(
|
|
144
|
+
* '<h1>ยินดีต้อนรับ</h1><p>ขอบคุณที่สมัครสมาชิก</p>',
|
|
145
|
+
* 'ยินดีต้อนรับสู่ระบบ',
|
|
146
|
+
* 'user@example.com',
|
|
147
|
+
* {
|
|
148
|
+
* recipient_name: 'สมชาย ใจดี',
|
|
149
|
+
* text_body: 'ยินดีต้อนรับ ขอบคุณที่สมัครสมาชิก',
|
|
150
|
+
* cc: ['manager@example.com'],
|
|
151
|
+
* bcc: ['archive@example.com'],
|
|
152
|
+
* attachments: [
|
|
153
|
+
* {
|
|
154
|
+
* filename: 'document.pdf',
|
|
155
|
+
* href: 'https://api.example.com/files/123e4567-e89b-12d3-a456-426614174000/content' // URL จาก File API
|
|
156
|
+
* }
|
|
157
|
+
* ]
|
|
158
|
+
* }
|
|
159
|
+
* );
|
|
160
|
+
* ```
|
|
161
|
+
*/
|
|
162
|
+
async sendRawEmail(htmlBody, subject, recipient, options) {
|
|
163
|
+
const request = {
|
|
164
|
+
html_body: htmlBody,
|
|
165
|
+
subject,
|
|
166
|
+
...(recipient.includes('@') ? { recipient_email: recipient } : { recipient_id: recipient }),
|
|
167
|
+
...(options?.recipient_name && { recipient_name: options.recipient_name }),
|
|
168
|
+
...(options?.text_body && { text_body: options.text_body }),
|
|
169
|
+
...(options?.cc && { cc: options.cc }),
|
|
170
|
+
...(options?.bcc && { bcc: options.bcc }),
|
|
171
|
+
...(options?.attachments && { attachments: options.attachments }),
|
|
172
|
+
...(options?.priority && { priority: options.priority }),
|
|
173
|
+
...(options?.scheduled_at && { scheduled_at: options.scheduled_at }),
|
|
174
|
+
...(options?.source && { source: options.source }),
|
|
175
|
+
...(options?.related_entity_id && { related_entity_id: options.related_entity_id }),
|
|
176
|
+
...(options?.related_entity_type && { related_entity_type: options.related_entity_type }),
|
|
177
|
+
};
|
|
178
|
+
return this.sendEmail(request);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
exports.EmailAPI = EmailAPI;
|
|
@@ -17,4 +17,7 @@ export { LineAPI } from './line.api';
|
|
|
17
17
|
export type { SendTextMessageRequest, SendStickerRequest, SendImageRequest, SendMessagesRequest, SendNotificationRequest, LineMessagePayload, LineMessageResponse, LineMessagingAvailabilityResponse, } from './line.api';
|
|
18
18
|
export { TodoAPI } from './todo.api';
|
|
19
19
|
export { UserAPI } from './user.api';
|
|
20
|
+
export { OtpAPI } from './otp.api';
|
|
21
|
+
export type { SendOTPRequest, SendOTPResponse, VerifyOTPRequest, VerifyOTPResponse } from './otp.api';
|
|
22
|
+
export { EmailAPI } from './email.api';
|
|
20
23
|
//# 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"}
|
|
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"}
|
package/dist/client/api/index.js
CHANGED
|
@@ -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.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.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");
|
|
@@ -29,3 +29,7 @@ var todo_api_1 = require("./todo.api");
|
|
|
29
29
|
Object.defineProperty(exports, "TodoAPI", { enumerable: true, get: function () { return todo_api_1.TodoAPI; } });
|
|
30
30
|
var user_api_1 = require("./user.api");
|
|
31
31
|
Object.defineProperty(exports, "UserAPI", { enumerable: true, get: function () { return user_api_1.UserAPI; } });
|
|
32
|
+
var otp_api_1 = require("./otp.api");
|
|
33
|
+
Object.defineProperty(exports, "OtpAPI", { enumerable: true, get: function () { return otp_api_1.OtpAPI; } });
|
|
34
|
+
var email_api_1 = require("./email.api");
|
|
35
|
+
Object.defineProperty(exports, "EmailAPI", { enumerable: true, get: function () { return email_api_1.EmailAPI; } });
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OTP Service API
|
|
3
|
+
*
|
|
4
|
+
* Handles OTP operations for external applications:
|
|
5
|
+
* - Send OTP via SMS or Email
|
|
6
|
+
* - Verify OTP code
|
|
7
|
+
*
|
|
8
|
+
* @requires API Key authentication
|
|
9
|
+
*/
|
|
10
|
+
import { AuthClient } from '../auth-client';
|
|
11
|
+
/**
|
|
12
|
+
* Send OTP Request
|
|
13
|
+
*/
|
|
14
|
+
export interface SendOTPRequest {
|
|
15
|
+
method: 'sms' | 'email';
|
|
16
|
+
recipient: string;
|
|
17
|
+
context?: string;
|
|
18
|
+
metadata?: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Send OTP Response
|
|
22
|
+
*/
|
|
23
|
+
export interface SendOTPResponse {
|
|
24
|
+
otp_id: string;
|
|
25
|
+
ref_code: string;
|
|
26
|
+
expires_at: Date;
|
|
27
|
+
masked_recipient: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Verify OTP Request
|
|
31
|
+
*/
|
|
32
|
+
export interface VerifyOTPRequest {
|
|
33
|
+
otp_id: string;
|
|
34
|
+
code: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Verify OTP Response
|
|
38
|
+
*/
|
|
39
|
+
export interface VerifyOTPResponse {
|
|
40
|
+
verified: boolean;
|
|
41
|
+
}
|
|
42
|
+
export declare class OtpAPI {
|
|
43
|
+
private client;
|
|
44
|
+
constructor(client: AuthClient);
|
|
45
|
+
/**
|
|
46
|
+
* Send OTP to recipient (SMS or Email)
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* // Send SMS OTP
|
|
51
|
+
* const result = await authClient.otp.sendOTP({
|
|
52
|
+
* method: 'sms',
|
|
53
|
+
* recipient: '0812345678',
|
|
54
|
+
* context: 'login'
|
|
55
|
+
* });
|
|
56
|
+
*
|
|
57
|
+
* console.log('OTP ID:', result.otp_id); // UUID
|
|
58
|
+
* console.log('Ref Code:', result.ref_code); // OTP-XXXXXX (for tracking)
|
|
59
|
+
* console.log('Expires at:', result.expires_at);
|
|
60
|
+
*
|
|
61
|
+
* // Send Email OTP
|
|
62
|
+
* const result = await authClient.otp.sendOTP({
|
|
63
|
+
* method: 'email',
|
|
64
|
+
* recipient: 'user@example.com',
|
|
65
|
+
* context: 'verification'
|
|
66
|
+
* });
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
sendOTP(request: SendOTPRequest): Promise<SendOTPResponse>;
|
|
70
|
+
/**
|
|
71
|
+
* Verify OTP code
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```typescript
|
|
75
|
+
* const result = await authClient.otp.verifyOTP({
|
|
76
|
+
* otp_id: '123e4567-e89b-12d3-a456-426614174000',
|
|
77
|
+
* code: '123456'
|
|
78
|
+
* });
|
|
79
|
+
*
|
|
80
|
+
* if (result.verified) {
|
|
81
|
+
* console.log('OTP verified successfully');
|
|
82
|
+
* }
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
verifyOTP(request: VerifyOTPRequest): Promise<VerifyOTPResponse>;
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=otp.api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"otp.api.d.ts","sourceRoot":"","sources":["../../../src/client/api/otp.api.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAG5C;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,KAAK,GAAG,OAAO,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,IAAI,CAAC;IACjB,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,qBAAa,MAAM;IACL,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,UAAU;IAEtC;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACG,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC;IAKhE;;;;;;;;;;;;;;OAcG;IACG,SAAS,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC;CAIvE"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* OTP Service API
|
|
4
|
+
*
|
|
5
|
+
* Handles OTP operations for external applications:
|
|
6
|
+
* - Send OTP via SMS or Email
|
|
7
|
+
* - Verify OTP code
|
|
8
|
+
*
|
|
9
|
+
* @requires API Key authentication
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.OtpAPI = void 0;
|
|
13
|
+
class OtpAPI {
|
|
14
|
+
constructor(client) {
|
|
15
|
+
this.client = client;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Send OTP to recipient (SMS or Email)
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* // Send SMS OTP
|
|
23
|
+
* const result = await authClient.otp.sendOTP({
|
|
24
|
+
* method: 'sms',
|
|
25
|
+
* recipient: '0812345678',
|
|
26
|
+
* context: 'login'
|
|
27
|
+
* });
|
|
28
|
+
*
|
|
29
|
+
* console.log('OTP ID:', result.otp_id); // UUID
|
|
30
|
+
* console.log('Ref Code:', result.ref_code); // OTP-XXXXXX (for tracking)
|
|
31
|
+
* console.log('Expires at:', result.expires_at);
|
|
32
|
+
*
|
|
33
|
+
* // Send Email OTP
|
|
34
|
+
* const result = await authClient.otp.sendOTP({
|
|
35
|
+
* method: 'email',
|
|
36
|
+
* recipient: 'user@example.com',
|
|
37
|
+
* context: 'verification'
|
|
38
|
+
* });
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
async sendOTP(request) {
|
|
42
|
+
const response = await this.client.post('/otp/send', request);
|
|
43
|
+
return response.data.data;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Verify OTP code
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* const result = await authClient.otp.verifyOTP({
|
|
51
|
+
* otp_id: '123e4567-e89b-12d3-a456-426614174000',
|
|
52
|
+
* code: '123456'
|
|
53
|
+
* });
|
|
54
|
+
*
|
|
55
|
+
* if (result.verified) {
|
|
56
|
+
* console.log('OTP verified successfully');
|
|
57
|
+
* }
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
async verifyOTP(request) {
|
|
61
|
+
const response = await this.client.post('/otp/verify', request);
|
|
62
|
+
return response.data.data;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
exports.OtpAPI = OtpAPI;
|
|
@@ -49,8 +49,12 @@ export declare class UserAPI {
|
|
|
49
49
|
/**
|
|
50
50
|
* Create a new user
|
|
51
51
|
*
|
|
52
|
+
* @description ถ้าไม่ระบุ password ระบบจะ auto generate และส่ง reset password link ไปทางอีเมล
|
|
53
|
+
* ถ้าระบุ password ระบบจะใช้ password ที่ส่งมาและส่ง welcome email พร้อม login link
|
|
54
|
+
*
|
|
52
55
|
* @example
|
|
53
56
|
* ```typescript
|
|
57
|
+
* // กรณีที่มี password - ระบบจะส่ง welcome email พร้อม login link
|
|
54
58
|
* const newUser = await authClient.user.create({
|
|
55
59
|
* email: "user@example.com",
|
|
56
60
|
* first_name: "สมชาย",
|
|
@@ -60,6 +64,17 @@ export declare class UserAPI {
|
|
|
60
64
|
* role_ids: ["role-123", "role-456"] // Optional: assign roles immediately
|
|
61
65
|
* });
|
|
62
66
|
* ```
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```typescript
|
|
70
|
+
* // กรณีที่ไม่มี password - ระบบจะ auto generate และส่ง welcome email พร้อม reset password link
|
|
71
|
+
* const newUser = await authClient.user.create({
|
|
72
|
+
* email: "user@example.com",
|
|
73
|
+
* first_name: "สมชาย",
|
|
74
|
+
* last_name: "ใจดี",
|
|
75
|
+
* code: "USR-2024-002"
|
|
76
|
+
* });
|
|
77
|
+
* ```
|
|
63
78
|
*/
|
|
64
79
|
create(userData: CreateUserRequest): Promise<User>;
|
|
65
80
|
/**
|
|
@@ -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
|
|
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"}
|
|
@@ -57,8 +57,12 @@ class UserAPI {
|
|
|
57
57
|
/**
|
|
58
58
|
* Create a new user
|
|
59
59
|
*
|
|
60
|
+
* @description ถ้าไม่ระบุ password ระบบจะ auto generate และส่ง reset password link ไปทางอีเมล
|
|
61
|
+
* ถ้าระบุ password ระบบจะใช้ password ที่ส่งมาและส่ง welcome email พร้อม login link
|
|
62
|
+
*
|
|
60
63
|
* @example
|
|
61
64
|
* ```typescript
|
|
65
|
+
* // กรณีที่มี password - ระบบจะส่ง welcome email พร้อม login link
|
|
62
66
|
* const newUser = await authClient.user.create({
|
|
63
67
|
* email: "user@example.com",
|
|
64
68
|
* first_name: "สมชาย",
|
|
@@ -68,6 +72,17 @@ class UserAPI {
|
|
|
68
72
|
* role_ids: ["role-123", "role-456"] // Optional: assign roles immediately
|
|
69
73
|
* });
|
|
70
74
|
* ```
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```typescript
|
|
78
|
+
* // กรณีที่ไม่มี password - ระบบจะ auto generate และส่ง welcome email พร้อม reset password link
|
|
79
|
+
* const newUser = await authClient.user.create({
|
|
80
|
+
* email: "user@example.com",
|
|
81
|
+
* first_name: "สมชาย",
|
|
82
|
+
* last_name: "ใจดี",
|
|
83
|
+
* code: "USR-2024-002"
|
|
84
|
+
* });
|
|
85
|
+
* ```
|
|
71
86
|
*/
|
|
72
87
|
async create(userData) {
|
|
73
88
|
const response = await this.client.post('/users', userData);
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';
|
|
9
9
|
import { AuthSdkConfig } from '../types';
|
|
10
|
-
import { AuthAPI, HealthAPI, SystemConfigAPI, FilesAPI, EventLogApi, LicenseAPI, OAuthAPI, OAuthConfig, LineAPI, TodoAPI, UserAPI } from './api';
|
|
10
|
+
import { AuthAPI, HealthAPI, SystemConfigAPI, FilesAPI, EventLogApi, LicenseAPI, OAuthAPI, OAuthConfig, LineAPI, TodoAPI, UserAPI, OtpAPI, EmailAPI } from './api';
|
|
11
11
|
export interface RefreshTokenCallbacks {
|
|
12
12
|
/**
|
|
13
13
|
* Get refresh token from storage
|
|
@@ -137,6 +137,8 @@ export declare class AuthClient {
|
|
|
137
137
|
readonly line: LineAPI;
|
|
138
138
|
readonly todo: TodoAPI;
|
|
139
139
|
readonly user: UserAPI;
|
|
140
|
+
readonly otp: OtpAPI;
|
|
141
|
+
readonly email: EmailAPI;
|
|
140
142
|
oauth?: OAuthAPI;
|
|
141
143
|
constructor(config: AuthSdkConfig);
|
|
142
144
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-client.d.ts","sourceRoot":"","sources":["../../src/client/auth-client.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAc,EAAE,aAAa,EAAE,kBAAkB,EAAE,aAAa,EAA8B,MAAM,OAAO,CAAC;AAC5G,OAAO,EAAE,aAAa,EAA8C,MAAM,UAAU,CAAC;AACrF,OAAO,EACL,OAAO,EACP,SAAS,EACT,eAAe,EACf,QAAQ,EACR,WAAW,EACX,UAAU,EACV,QAAQ,EACR,WAAW,EACX,OAAO,EACP,OAAO,EACP,OAAO,
|
|
1
|
+
{"version":3,"file":"auth-client.d.ts","sourceRoot":"","sources":["../../src/client/auth-client.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAc,EAA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3B;;OAEG;YACW,oBAAoB;IAgBlC;;OAEG;YACW,cAAc;IAmB5B;;;OAGG;YACW,SAAS;IAqDvB;;OAEG;IACG,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC;IAOtC;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACG,iCAAiC,CAAC,OAAO,EAAE,wBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC;IAWzF;;OAEG;IACH,kCAAkC,IAAI,IAAI;IAO1C;;OAEG;YACW,2BAA2B;IASzC;;OAEG;YACW,kCAAkC;IAmBhD;;OAEG;IACH,OAAO,CAAC,gCAAgC;IAaxC;;OAEG;IACH,OAAO,CAAC,+BAA+B;IAOvC;;;;;;OAMG;IACH,OAAO,CAAC,sBAAsB;IAiE9B;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAe9B;;OAEG;IACG,6BAA6B,IAAI,OAAO,CAAC,IAAI,CAAC;IAMpD;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACG,yBAAyB,CAAC,OAAO,EAAE,0BAA0B,GAAG,OAAO,CAAC,IAAI,CAAC;IAsDnF;;OAEG;IACH,0BAA0B,IAAI,IAAI;IAyBlC;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAkB1B;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAuB9B;;OAEG;IACH,OAAO,CAAC,uBAAuB;IAc/B;;OAEG;IACH,OAAO,CAAC,uBAAuB;IAW/B;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAmC5B;;OAEG;IACH,OAAO,CAAC,sBAAsB;CA0B/B"}
|
|
@@ -185,6 +185,8 @@ class AuthClient {
|
|
|
185
185
|
this.line = new api_1.LineAPI(this);
|
|
186
186
|
this.todo = new api_1.TodoAPI(this);
|
|
187
187
|
this.user = new api_1.UserAPI(this);
|
|
188
|
+
this.otp = new api_1.OtpAPI(this);
|
|
189
|
+
this.email = new api_1.EmailAPI(this);
|
|
188
190
|
}
|
|
189
191
|
/**
|
|
190
192
|
* Initialize OAuth client for OAuth 2.0 flows
|
|
@@ -650,9 +652,7 @@ class AuthClient {
|
|
|
650
652
|
return;
|
|
651
653
|
}
|
|
652
654
|
// คำนวณ session expiration times จาก config
|
|
653
|
-
const inactivityTimeoutMinutes = inactivityEnabled
|
|
654
|
-
? this.sessionManagementConfig.inactivity.timeout_minutes
|
|
655
|
-
: null;
|
|
655
|
+
const inactivityTimeoutMinutes = inactivityEnabled ? this.sessionManagementConfig.inactivity.timeout_minutes : null;
|
|
656
656
|
const lifetimeMaxMinutes = lifetimeEnabled && this.sessionManagementConfig.lifetime.max_lifetime_days
|
|
657
657
|
? this.sessionManagementConfig.lifetime.max_lifetime_days * 24 * 60 // Convert days to minutes
|
|
658
658
|
: null;
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Email Types for Auth SDK
|
|
3
|
+
*
|
|
4
|
+
* @description Types สำหรับ email operations ใน SDK
|
|
5
|
+
* รองรับทั้ง Template Mode และ Raw HTML Mode
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Send Email Request - ข้อมูลสำหรับส่ง email
|
|
9
|
+
*
|
|
10
|
+
* @description รองรับทั้ง Template Mode และ Raw HTML Mode
|
|
11
|
+
*
|
|
12
|
+
* === Template Mode ===
|
|
13
|
+
* - template_code (required) - Template code จาก database
|
|
14
|
+
* - template_data (optional) - ข้อมูลสำหรับ render template
|
|
15
|
+
* - subject (optional) - Override subject จาก template
|
|
16
|
+
* - language (optional) - Template language (default: 'th')
|
|
17
|
+
*
|
|
18
|
+
* === Raw HTML Mode ===
|
|
19
|
+
* - html_body (required) - HTML content โดยตรง
|
|
20
|
+
* - subject (required) - Email subject
|
|
21
|
+
* - text_body (optional) - Plain text version (auto-generated ถ้าไม่ระบุ)
|
|
22
|
+
*
|
|
23
|
+
* === Recipients ===
|
|
24
|
+
* - recipient_email (required ถ้าไม่มี recipient_id) - Email address
|
|
25
|
+
* - recipient_id (required ถ้าไม่มี recipient_email) - User ID (ส่งผ่าน notification system)
|
|
26
|
+
* - recipient_name (optional) - Display name
|
|
27
|
+
* - cc (optional) - CC recipients (string หรือ array)
|
|
28
|
+
* - bcc (optional) - BCC recipients (string หรือ array)
|
|
29
|
+
*
|
|
30
|
+
* === Attachments ===
|
|
31
|
+
* - attachments (optional) - Array ของไฟล์แนบ
|
|
32
|
+
*
|
|
33
|
+
* === Validation ===
|
|
34
|
+
* - ต้องมี template_code หรือ html_body อย่างใดอย่างหนึ่ง (mutual exclusivity)
|
|
35
|
+
* - ถ้ามี template_code: subject เป็น optional (ใช้จาก template)
|
|
36
|
+
* - ถ้ามี html_body: subject เป็น required
|
|
37
|
+
* - ต้องมี recipient_email หรือ recipient_id อย่างใดอย่างหนึ่ง
|
|
38
|
+
*
|
|
39
|
+
* @example Template Mode
|
|
40
|
+
* ```typescript
|
|
41
|
+
* {
|
|
42
|
+
* template_code: 'welcome_email',
|
|
43
|
+
* template_data: {
|
|
44
|
+
* userName: 'สมชาย ใจดี',
|
|
45
|
+
* activationLink: 'https://app.com/activate?token=xxx'
|
|
46
|
+
* },
|
|
47
|
+
* recipient_email: 'user@example.com',
|
|
48
|
+
* recipient_name: 'สมชาย ใจดี',
|
|
49
|
+
* language: 'th',
|
|
50
|
+
* cc: ['manager@example.com'],
|
|
51
|
+
* attachments: [
|
|
52
|
+
* {
|
|
53
|
+
* filename: 'welcome.pdf',
|
|
54
|
+
* href: 'https://api.example.com/files/123e4567-e89b-12d3-a456-426614174000/content'
|
|
55
|
+
* }
|
|
56
|
+
* ]
|
|
57
|
+
* }
|
|
58
|
+
* ```
|
|
59
|
+
*
|
|
60
|
+
* @example Raw HTML Mode
|
|
61
|
+
* ```typescript
|
|
62
|
+
* {
|
|
63
|
+
* html_body: '<h1>ยินดีต้อนรับ</h1><p>ขอบคุณที่สมัครสมาชิก</p>',
|
|
64
|
+
* subject: 'ยินดีต้อนรับสู่ระบบ',
|
|
65
|
+
* recipient_email: 'user@example.com',
|
|
66
|
+
* text_body: 'ยินดีต้อนรับ ขอบคุณที่สมัครสมาชิก',
|
|
67
|
+
* cc: ['manager@example.com'],
|
|
68
|
+
* bcc: ['archive@example.com']
|
|
69
|
+
* }
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
export interface SendEmailRequest {
|
|
73
|
+
/**
|
|
74
|
+
* Template code จาก database (required สำหรับ Template Mode)
|
|
75
|
+
* @example "welcome_email"
|
|
76
|
+
*/
|
|
77
|
+
template_code?: string;
|
|
78
|
+
/**
|
|
79
|
+
* Template data สำหรับ render template (optional)
|
|
80
|
+
* @example { "userName": "John", "activationLink": "https://..." }
|
|
81
|
+
*/
|
|
82
|
+
template_data?: Record<string, any>;
|
|
83
|
+
/**
|
|
84
|
+
* Template language (optional, default: 'th')
|
|
85
|
+
* @example "th" | "en"
|
|
86
|
+
*/
|
|
87
|
+
language?: 'th' | 'en';
|
|
88
|
+
/**
|
|
89
|
+
* Override subject จาก template (optional)
|
|
90
|
+
* ใช้เฉพาะเมื่อต้องการ override subject ที่กำหนดไว้ใน template
|
|
91
|
+
*/
|
|
92
|
+
subject?: string;
|
|
93
|
+
/**
|
|
94
|
+
* HTML content โดยตรง (required สำหรับ Raw HTML Mode)
|
|
95
|
+
* @example "<h1>Hello</h1><p>World</p>"
|
|
96
|
+
*/
|
|
97
|
+
html_body?: string;
|
|
98
|
+
/**
|
|
99
|
+
* Plain text version (optional)
|
|
100
|
+
* Auto-generated จาก html_body ถ้าไม่ระบุ
|
|
101
|
+
*/
|
|
102
|
+
text_body?: string;
|
|
103
|
+
/**
|
|
104
|
+
* Email address ของผู้รับ (required ถ้าไม่มี recipient_id)
|
|
105
|
+
* @example "user@example.com"
|
|
106
|
+
*/
|
|
107
|
+
recipient_email?: string;
|
|
108
|
+
/**
|
|
109
|
+
* User ID ของผู้รับ (required ถ้าไม่มี recipient_email)
|
|
110
|
+
* จะส่งผ่าน notification system และสร้าง notification record
|
|
111
|
+
* @example "user-123e4567-e89b-12d3-a456-426614174000"
|
|
112
|
+
*/
|
|
113
|
+
recipient_id?: string;
|
|
114
|
+
/**
|
|
115
|
+
* Display name ของผู้รับ (optional)
|
|
116
|
+
* @example "สมชาย ใจดี"
|
|
117
|
+
*/
|
|
118
|
+
recipient_name?: string;
|
|
119
|
+
/**
|
|
120
|
+
* CC recipients (optional)
|
|
121
|
+
* รองรับทั้ง string (single) และ array (multiple)
|
|
122
|
+
* @example "manager@example.com" หรือ ["manager@example.com", "team@example.com"]
|
|
123
|
+
*/
|
|
124
|
+
cc?: string | string[];
|
|
125
|
+
/**
|
|
126
|
+
* BCC recipients (optional)
|
|
127
|
+
* รองรับทั้ง string (single) และ array (multiple)
|
|
128
|
+
* @example "archive@example.com" หรือ ["archive@example.com", "backup@example.com"]
|
|
129
|
+
*/
|
|
130
|
+
bcc?: string | string[];
|
|
131
|
+
/**
|
|
132
|
+
* Attachments (optional)
|
|
133
|
+
* Array ของไฟล์แนบ
|
|
134
|
+
*
|
|
135
|
+
* ✅ **ใช้ URL (`href`) เท่านั้น** - Simple และ consistent
|
|
136
|
+
*
|
|
137
|
+
* **การใช้งาน:**
|
|
138
|
+
* 1. External applications: Upload ไฟล์ผ่าน File API (`/files/upload`) แล้วได้ URL กลับมา
|
|
139
|
+
* 2. Internal applications: ใช้ URL จาก storage service หรือ `/files/:id/content`
|
|
140
|
+
* 3. Cloud storage: ใช้ URL จาก Azure Blob Storage, AWS S3, Google Cloud Storage, etc.
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* ```typescript
|
|
144
|
+
* [
|
|
145
|
+
* {
|
|
146
|
+
* filename: 'report.pdf',
|
|
147
|
+
* href: 'https://api.example.com/files/123e4567-e89b-12d3-a456-426614174000/content'
|
|
148
|
+
* },
|
|
149
|
+
* {
|
|
150
|
+
* filename: 'document.pdf',
|
|
151
|
+
* href: 'https://storage.azure.com/container/document.pdf'
|
|
152
|
+
* }
|
|
153
|
+
* ]
|
|
154
|
+
* ```
|
|
155
|
+
*/
|
|
156
|
+
attachments?: Array<{
|
|
157
|
+
filename: string;
|
|
158
|
+
href: string;
|
|
159
|
+
content_type?: string;
|
|
160
|
+
}>;
|
|
161
|
+
/**
|
|
162
|
+
* Priority (optional, default: 'normal')
|
|
163
|
+
* @example "low" | "normal" | "high" | "urgent"
|
|
164
|
+
*/
|
|
165
|
+
priority?: 'low' | 'normal' | 'high' | 'urgent';
|
|
166
|
+
/**
|
|
167
|
+
* Scheduled send time (optional)
|
|
168
|
+
* @example "2024-01-20T10:00:00Z"
|
|
169
|
+
*/
|
|
170
|
+
scheduled_at?: Date | string;
|
|
171
|
+
/**
|
|
172
|
+
* Source identifier (optional)
|
|
173
|
+
* สำหรับ tracking แหล่งที่มาของ email
|
|
174
|
+
* @example "user_registration" | "order_confirmation"
|
|
175
|
+
*/
|
|
176
|
+
source?: string;
|
|
177
|
+
/**
|
|
178
|
+
* Related entity ID (optional)
|
|
179
|
+
* สำหรับเชื่อมโยงกับ entity อื่น
|
|
180
|
+
*/
|
|
181
|
+
related_entity_id?: string;
|
|
182
|
+
/**
|
|
183
|
+
* Related entity type (optional)
|
|
184
|
+
* @example "user" | "order" | "invoice"
|
|
185
|
+
*/
|
|
186
|
+
related_entity_type?: string;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Send Email Response - ผลลัพธ์จากการส่ง email
|
|
190
|
+
*
|
|
191
|
+
* @description Response เมื่อส่ง email สำเร็จ
|
|
192
|
+
*
|
|
193
|
+
* @properties
|
|
194
|
+
* - email_id: รหัส email queue (required) UUID ของ email ที่ถูกเพิ่มเข้า queue
|
|
195
|
+
* - status: สถานะ email (required) 'queued' | 'sent' | 'failed'
|
|
196
|
+
* - recipient_email: อีเมลผู้รับ (required)
|
|
197
|
+
* - subject: หัวข้ออีเมล (required)
|
|
198
|
+
* - queued_at: เวลาที่ queue (required) timestamp เมื่อ email ถูกเพิ่มเข้า queue
|
|
199
|
+
* - message_id: รหัสข้อความ (optional) message ID จาก SMTP server (ถ้าส่งทันที)
|
|
200
|
+
*
|
|
201
|
+
* @example
|
|
202
|
+
* ```typescript
|
|
203
|
+
* {
|
|
204
|
+
* email_id: 'email123e4567-e89b-12d3-a456-426614174000',
|
|
205
|
+
* status: 'queued',
|
|
206
|
+
* recipient_email: 'user@example.com',
|
|
207
|
+
* subject: 'ยินดีต้อนรับสู่ระบบ',
|
|
208
|
+
* queued_at: new Date('2024-01-20T10:00:00Z'),
|
|
209
|
+
* message_id: '0100018d-f3e4-4697-9d51-d685ba19f288-000000'
|
|
210
|
+
* }
|
|
211
|
+
* ```
|
|
212
|
+
*/
|
|
213
|
+
export interface SendEmailResponse {
|
|
214
|
+
/**
|
|
215
|
+
* Email queue ID (UUID)
|
|
216
|
+
*/
|
|
217
|
+
email_id: string;
|
|
218
|
+
/**
|
|
219
|
+
* Email status
|
|
220
|
+
* - 'queued': ถูกเพิ่มเข้า queue แล้ว (รอส่ง)
|
|
221
|
+
* - 'sent': ส่งสำเร็จแล้ว
|
|
222
|
+
* - 'failed': ส่งล้มเหลว
|
|
223
|
+
*/
|
|
224
|
+
status: 'queued' | 'sent' | 'failed';
|
|
225
|
+
/**
|
|
226
|
+
* Recipient email address
|
|
227
|
+
*/
|
|
228
|
+
recipient_email: string;
|
|
229
|
+
/**
|
|
230
|
+
* Email subject
|
|
231
|
+
*/
|
|
232
|
+
subject: string;
|
|
233
|
+
/**
|
|
234
|
+
* Timestamp when email was queued
|
|
235
|
+
*/
|
|
236
|
+
queued_at: Date | string;
|
|
237
|
+
/**
|
|
238
|
+
* Message ID from SMTP server (optional)
|
|
239
|
+
* มีเฉพาะเมื่อส่งทันที (ไม่ผ่าน queue)
|
|
240
|
+
*/
|
|
241
|
+
message_id?: string;
|
|
242
|
+
}
|
|
243
|
+
//# sourceMappingURL=email.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"email.types.d.ts","sourceRoot":"","sources":["../../src/types/email.types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;;;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,CAAC;CAC9B;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;;;;OAKG;IACH,MAAM,EAAE,QAAQ,GAAG,MAAM,GAAG,QAAQ,CAAC;IAErC;;OAEG;IACH,eAAe,EAAE,MAAM,CAAC;IAExB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,SAAS,EAAE,IAAI,GAAG,MAAM,CAAC;IAEzB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -141,6 +141,7 @@ export interface ApiKeyAuthModuleConfig {
|
|
|
141
141
|
cacheTimeout?: number;
|
|
142
142
|
}
|
|
143
143
|
export * from './auth.types';
|
|
144
|
+
export * from './email.types';
|
|
144
145
|
export * from './event-log.types';
|
|
145
146
|
export * from './file.types';
|
|
146
147
|
export * from './system-config.types';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,WAAW,CAAC,CAAC;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,CAAC,CAAC;IACT,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE;QACL,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACpB,CAAC;CACH;AAED;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,QA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ports, "__esModule", { value: true });
|
|
|
24
24
|
// ============================================================================
|
|
25
25
|
// Authentication Types
|
|
26
26
|
__exportStar(require("./auth.types"), exports);
|
|
27
|
+
// Email Types
|
|
28
|
+
__exportStar(require("./email.types"), exports);
|
|
27
29
|
// Event Log Types
|
|
28
30
|
__exportStar(require("./event-log.types"), exports);
|
|
29
31
|
// File Types
|
|
@@ -61,6 +61,9 @@ export interface User {
|
|
|
61
61
|
/**
|
|
62
62
|
* Create User Request - ข้อมูลสำหรับสร้างผู้ใช้ใหม่
|
|
63
63
|
* Matches CreateUserRequestDto from @win-portal/shared
|
|
64
|
+
*
|
|
65
|
+
* @description ถ้าไม่ระบุ password ระบบจะ auto generate และส่ง reset password link ไปทางอีเมล
|
|
66
|
+
* ถ้าระบุ password ระบบจะใช้ password ที่ส่งมาและส่ง welcome email พร้อม login link
|
|
64
67
|
*/
|
|
65
68
|
export interface CreateUserRequest {
|
|
66
69
|
email: string;
|
|
@@ -73,7 +76,7 @@ export interface CreateUserRequest {
|
|
|
73
76
|
phone_number?: string;
|
|
74
77
|
avatar_file_id?: string;
|
|
75
78
|
signature_file_id?: string;
|
|
76
|
-
password
|
|
79
|
+
password?: string;
|
|
77
80
|
ignore_password_policies?: boolean;
|
|
78
81
|
role_ids?: string[];
|
|
79
82
|
metadata?: Record<string, any>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.types.d.ts","sourceRoot":"","sources":["../../src/types/user.types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;GAGG;AACH,MAAM,WAAW,IAAI;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,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