@ariary/notification 1.0.1 → 1.0.2

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 CHANGED
@@ -1,76 +1,46 @@
1
- # @ariary/sms
2
-
3
- SDK SMS et Notification Task pour l'API Ariary
4
-
5
- ## Installation
6
-
7
- ```bash
8
- npm install @ariary/sms
9
- ```
10
-
11
- ## Usage
12
-
13
- ### Initialisation
14
-
15
- ```typescript
16
- import { SmsSdk } from '@ariary/sms';
17
-
18
- const sdk = new SmsSdk({
19
- projectId: 'your-project-id',
20
- secretId: 'your-secret-id',
21
- baseUrl: 'https://back.ariari.mg/payment/api-docs'
22
- });
23
- ```
24
-
25
- ### SMS Service
26
-
27
- ```typescript
28
- // Envoyer un SMS unique
29
- await sdk.sms.notify('Hello World', '261234567890');
30
-
31
- // Envoyer un SMS à plusieurs destinataires
32
- await sdk.sms.notify('Hello World', ['261234567890', '261234567891']);
33
-
34
- // Envoyer des messages différents (bulk)
35
- await sdk.sms.notifyBulk([
36
- { message: 'Message 1', numbers: ['261234567890'] },
37
- { message: 'Message 2', numbers: ['261234567891'] }
38
- ]);
39
-
40
- // Récupérer l'historique SMS
41
- const smsList = await sdk.sms.getAll();
42
- ```
43
-
44
- ### NotifTask Service
45
-
46
- ```typescript
47
- // Créer une tâche de notification
48
- const task = await sdk.notifTask.create({
49
- message: 'Hello World',
50
- phones: ['261234567890', '261234567891']
51
- });
52
-
53
- // Récupérer toutes les tâches
54
- const tasks = await sdk.notifTask.findAll('project-id');
55
-
56
- // Récupérer une tâche
57
- const task = await sdk.notifTask.findOne('task-id');
58
-
59
- // Mettre à jour une tâche
60
- await sdk.notifTask.update('task-id', {
61
- message: 'Updated message'
62
- });
63
-
64
- // Récupérer les détails SMS d'une tâche
65
- const details = await sdk.notifTask.getSmsDetails('task-id');
66
-
67
- // Réessayer les SMS échoués
68
- await sdk.notifTask.retryFailedSms('task-id');
69
-
70
- // Supprimer une tâche
71
- await sdk.notifTask.remove('task-id');
72
- ```
73
-
74
- ## License
75
-
76
- ISC
1
+ # @ariary/notification
2
+
3
+ Un outil pour envoyer des SMS via Ariary et suivre leur état.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @ariary/notification
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ### Initialisation
14
+
15
+ ```typescript
16
+ import { Ariari } from '@ariary/notification';
17
+
18
+ Ariari.config({
19
+ projectId: 'your-project-id',
20
+ secretId: 'your-secret-id'
21
+ });
22
+ ```
23
+
24
+ ## Notifications
25
+
26
+ ```typescript
27
+ // SMS
28
+ const sms = await Ariari.notification.send({ phone: ['261345678901', '261345678902'], message: 'Hello' });
29
+ const bulkSms = await Ariari.notification.sendBulk([
30
+ { phone: '261345678901', message: 'Message 1' },
31
+ { phone: '261345678902', message: 'Message 2' }
32
+ ]);
33
+ const allSms = await Ariari.notification.getAll();
34
+
35
+ // Notification Tasks
36
+ const tasks = await Ariari.notification.task.findAll('projectId');
37
+ const task = await Ariari.notification.task.findOne(taskId);
38
+ const updatedTask = await Ariari.notification.task.update(taskId, { message: 'New' });
39
+ const deleted = await Ariari.notification.task.delete(taskId);
40
+ const smsDetails = await Ariari.notification.task.getSmsDetails(taskId);
41
+ const retried = await Ariari.notification.task.retryFailedSms(taskId);
42
+ ```
43
+
44
+ ## License
45
+
46
+ ISC
package/dist/index.d.mts CHANGED
@@ -1,18 +1,133 @@
1
- import { SmsService } from './sms/index.mjs';
2
- export { BulkSmsDto, BulkSmsResponseDto, CreateSmsDto, MultiSmsResponseDto, ResponseSmsDto, SendSmsDto, SendSmsResponseDto } from './sms/index.mjs';
3
- import { NotifTaskService } from './notif-task/index.mjs';
4
- export { CreateNotifTaskDto, NotifTaskDetailsDto, ResponseNotifTaskDto, RetryFailedSmsResponseDto, SmsDetail, UpdateNotifTaskDto } from './notif-task/index.mjs';
5
- import { A as ApiConfig } from './client-BOI4a9h5.mjs';
6
- export { a as ApiClient } from './client-BOI4a9h5.mjs';
1
+ interface CreateSmsDto {
2
+ message: string;
3
+ phone: string;
4
+ }
5
+ interface SendSmsDto {
6
+ message: string;
7
+ phones: string[];
8
+ }
9
+ interface BulkSmsDto {
10
+ messages: {
11
+ phones: string[];
12
+ message: string;
13
+ }[];
14
+ }
15
+ interface SendSmsResponseDto {
16
+ id: string;
17
+ message: string;
18
+ phone: string;
19
+ status: string;
20
+ createdAt: string;
21
+ }
22
+ interface ResponseSmsDto {
23
+ id: string;
24
+ message: string;
25
+ phone: string;
26
+ status: string;
27
+ createdAt: string;
28
+ updatedAt: string;
29
+ }
30
+ interface MultiSmsResponseDto {
31
+ status: string;
32
+ data: {
33
+ id: string;
34
+ message: string;
35
+ phone: string;
36
+ status: string;
37
+ }[];
38
+ }
39
+ interface BulkSmsResponseDto {
40
+ status: string;
41
+ data: {
42
+ id: string;
43
+ message: string;
44
+ phone: string;
45
+ status: string;
46
+ }[];
47
+ }
48
+ interface CreateNotifTaskDto {
49
+ message: string;
50
+ phones: string[];
51
+ }
52
+ interface UpdateNotifTaskDto {
53
+ message?: string;
54
+ phones?: string[];
55
+ }
56
+ interface ResponseNotifTaskDto {
57
+ id: string;
58
+ message: string;
59
+ phones: string[];
60
+ status: string;
61
+ createdAt: string;
62
+ updatedAt: string;
63
+ }
64
+ interface SmsDetail {
65
+ id: string;
66
+ phone: string;
67
+ message: string;
68
+ status: string;
69
+ attempts: number;
70
+ lastAttempt?: string;
71
+ createdAt: string;
72
+ updatedAt: string;
73
+ }
74
+ interface NotifTaskDetailsDto {
75
+ id: string;
76
+ message: string;
77
+ status: string;
78
+ totalSms: number;
79
+ successCount: number;
80
+ failedCount: number;
81
+ pendingCount: number;
82
+ smsDetails: SmsDetail[];
83
+ createdAt: string;
84
+ updatedAt: string;
85
+ }
86
+ interface RetryFailedSmsResponseDto {
87
+ status: string;
88
+ message: string;
89
+ retried?: number;
90
+ }
91
+
92
+ interface SmsApi {
93
+ send(data: {
94
+ phone: string | string[];
95
+ message: string;
96
+ }): Promise<MultiSmsResponseDto>;
97
+ sendBulk(messages: {
98
+ phone: string | string[];
99
+ message: string;
100
+ }[]): Promise<BulkSmsResponseDto>;
101
+ getAll(): Promise<ResponseSmsDto[]>;
102
+ }
103
+ interface NotifTaskApi {
104
+ findAll(projectId: string): Promise<ResponseNotifTaskDto[]>;
105
+ findOne(id: string): Promise<ResponseNotifTaskDto>;
106
+ update(id: string, data: UpdateNotifTaskDto): Promise<ResponseNotifTaskDto>;
107
+ delete(id: string): Promise<ResponseNotifTaskDto>;
108
+ getSmsDetails(id: string): Promise<NotifTaskDetailsDto>;
109
+ retryFailedSms(id: string): Promise<RetryFailedSmsResponseDto>;
110
+ }
111
+ interface NotificationService extends SmsApi {
112
+ task: NotifTaskApi;
113
+ }
114
+ declare const notificationService: NotificationService;
115
+
116
+ interface ApiConfig {
117
+ projectId: string;
118
+ secretId: string;
119
+ baseUrl?: string;
120
+ }
121
+ declare function setConfig(cfg: ApiConfig): void;
122
+ declare function getConfig(): ApiConfig | null;
7
123
 
8
- /**
9
- * SDK pour SMS et Notification Tasks Ariary
10
- */
11
- declare class SmsSdk {
12
- private client;
13
- sms: SmsService;
14
- notifTask: NotifTaskService;
15
- constructor(config: ApiConfig);
124
+ declare class AriariBridge {
125
+ private static instance;
126
+ private constructor();
127
+ static getInstance(): AriariBridge;
128
+ config(cfg: ApiConfig): void;
129
+ get notification(): NotificationService;
16
130
  }
131
+ declare const Ariari: AriariBridge;
17
132
 
18
- export { ApiConfig, NotifTaskService, SmsSdk, SmsService };
133
+ export { type ApiConfig, Ariari, type BulkSmsDto, type BulkSmsResponseDto, type CreateNotifTaskDto, type CreateSmsDto, type MultiSmsResponseDto, type NotifTaskApi, type NotifTaskDetailsDto, type NotificationService, type ResponseNotifTaskDto, type ResponseSmsDto, type RetryFailedSmsResponseDto, type SendSmsDto, type SendSmsResponseDto, type SmsApi, type SmsDetail, type UpdateNotifTaskDto, getConfig, notificationService, setConfig };
package/dist/index.d.ts CHANGED
@@ -1,18 +1,133 @@
1
- import { SmsService } from './sms/index.js';
2
- export { BulkSmsDto, BulkSmsResponseDto, CreateSmsDto, MultiSmsResponseDto, ResponseSmsDto, SendSmsDto, SendSmsResponseDto } from './sms/index.js';
3
- import { NotifTaskService } from './notif-task/index.js';
4
- export { CreateNotifTaskDto, NotifTaskDetailsDto, ResponseNotifTaskDto, RetryFailedSmsResponseDto, SmsDetail, UpdateNotifTaskDto } from './notif-task/index.js';
5
- import { A as ApiConfig } from './client-BOI4a9h5.js';
6
- export { a as ApiClient } from './client-BOI4a9h5.js';
1
+ interface CreateSmsDto {
2
+ message: string;
3
+ phone: string;
4
+ }
5
+ interface SendSmsDto {
6
+ message: string;
7
+ phones: string[];
8
+ }
9
+ interface BulkSmsDto {
10
+ messages: {
11
+ phones: string[];
12
+ message: string;
13
+ }[];
14
+ }
15
+ interface SendSmsResponseDto {
16
+ id: string;
17
+ message: string;
18
+ phone: string;
19
+ status: string;
20
+ createdAt: string;
21
+ }
22
+ interface ResponseSmsDto {
23
+ id: string;
24
+ message: string;
25
+ phone: string;
26
+ status: string;
27
+ createdAt: string;
28
+ updatedAt: string;
29
+ }
30
+ interface MultiSmsResponseDto {
31
+ status: string;
32
+ data: {
33
+ id: string;
34
+ message: string;
35
+ phone: string;
36
+ status: string;
37
+ }[];
38
+ }
39
+ interface BulkSmsResponseDto {
40
+ status: string;
41
+ data: {
42
+ id: string;
43
+ message: string;
44
+ phone: string;
45
+ status: string;
46
+ }[];
47
+ }
48
+ interface CreateNotifTaskDto {
49
+ message: string;
50
+ phones: string[];
51
+ }
52
+ interface UpdateNotifTaskDto {
53
+ message?: string;
54
+ phones?: string[];
55
+ }
56
+ interface ResponseNotifTaskDto {
57
+ id: string;
58
+ message: string;
59
+ phones: string[];
60
+ status: string;
61
+ createdAt: string;
62
+ updatedAt: string;
63
+ }
64
+ interface SmsDetail {
65
+ id: string;
66
+ phone: string;
67
+ message: string;
68
+ status: string;
69
+ attempts: number;
70
+ lastAttempt?: string;
71
+ createdAt: string;
72
+ updatedAt: string;
73
+ }
74
+ interface NotifTaskDetailsDto {
75
+ id: string;
76
+ message: string;
77
+ status: string;
78
+ totalSms: number;
79
+ successCount: number;
80
+ failedCount: number;
81
+ pendingCount: number;
82
+ smsDetails: SmsDetail[];
83
+ createdAt: string;
84
+ updatedAt: string;
85
+ }
86
+ interface RetryFailedSmsResponseDto {
87
+ status: string;
88
+ message: string;
89
+ retried?: number;
90
+ }
91
+
92
+ interface SmsApi {
93
+ send(data: {
94
+ phone: string | string[];
95
+ message: string;
96
+ }): Promise<MultiSmsResponseDto>;
97
+ sendBulk(messages: {
98
+ phone: string | string[];
99
+ message: string;
100
+ }[]): Promise<BulkSmsResponseDto>;
101
+ getAll(): Promise<ResponseSmsDto[]>;
102
+ }
103
+ interface NotifTaskApi {
104
+ findAll(projectId: string): Promise<ResponseNotifTaskDto[]>;
105
+ findOne(id: string): Promise<ResponseNotifTaskDto>;
106
+ update(id: string, data: UpdateNotifTaskDto): Promise<ResponseNotifTaskDto>;
107
+ delete(id: string): Promise<ResponseNotifTaskDto>;
108
+ getSmsDetails(id: string): Promise<NotifTaskDetailsDto>;
109
+ retryFailedSms(id: string): Promise<RetryFailedSmsResponseDto>;
110
+ }
111
+ interface NotificationService extends SmsApi {
112
+ task: NotifTaskApi;
113
+ }
114
+ declare const notificationService: NotificationService;
115
+
116
+ interface ApiConfig {
117
+ projectId: string;
118
+ secretId: string;
119
+ baseUrl?: string;
120
+ }
121
+ declare function setConfig(cfg: ApiConfig): void;
122
+ declare function getConfig(): ApiConfig | null;
7
123
 
8
- /**
9
- * SDK pour SMS et Notification Tasks Ariary
10
- */
11
- declare class SmsSdk {
12
- private client;
13
- sms: SmsService;
14
- notifTask: NotifTaskService;
15
- constructor(config: ApiConfig);
124
+ declare class AriariBridge {
125
+ private static instance;
126
+ private constructor();
127
+ static getInstance(): AriariBridge;
128
+ config(cfg: ApiConfig): void;
129
+ get notification(): NotificationService;
16
130
  }
131
+ declare const Ariari: AriariBridge;
17
132
 
18
- export { ApiConfig, NotifTaskService, SmsSdk, SmsService };
133
+ export { type ApiConfig, Ariari, type BulkSmsDto, type BulkSmsResponseDto, type CreateNotifTaskDto, type CreateSmsDto, type MultiSmsResponseDto, type NotifTaskApi, type NotifTaskDetailsDto, type NotificationService, type ResponseNotifTaskDto, type ResponseSmsDto, type RetryFailedSmsResponseDto, type SendSmsDto, type SendSmsResponseDto, type SmsApi, type SmsDetail, type UpdateNotifTaskDto, getConfig, notificationService, setConfig };