@ariary/notification 2.0.7 → 2.0.9

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,4 +1,3 @@
1
- # Ariari Notification
2
1
 
3
2
  Simple SDK for sending SMS notifications.
4
3
 
@@ -8,41 +7,40 @@ Simple SDK for sending SMS notifications.
8
7
  npm install @ariary/notification
9
8
  ```
10
9
 
11
- ## Usage
12
-
13
- ### Configuration
10
+ ## Imports
14
11
 
15
12
  ```typescript
16
- import Ariari from '@ariary/notification';
13
+ import { Ariari, Task } from '@ariary/notification';
14
+ ```
15
+ ## Configuration
17
16
 
17
+ ```typescript
18
18
  Ariari.config({
19
19
  projectId: 'your-project-id',
20
20
  secretId: 'your-secret-id'
21
21
  });
22
22
  ```
23
23
 
24
+ ## Send Messages
25
+
24
26
  ```typescript
25
27
  const task = await Ariari.send(
26
28
  { phone: '+261123456789', message: 'Message 1' },
27
29
  { phone: ['+261987654321', '+261555555555'], message: 'Message 2' }
28
30
  );
29
-
30
-
31
31
  ```
32
32
 
33
- Or check an existing task by ID:
33
+ ## Check Task Status
34
34
 
35
35
  ```typescript
36
- const task = new Ariari.Task( 'id');
37
36
 
38
37
  const status = await task.status();
39
- // Returns SMS details: status (PENDING, SENT, FAILED),
38
+ // Returns SMS details: status (PENDING, SENT, FAILED)
40
39
 
41
40
  const details = await task.smsDetails();
42
-
43
41
  ```
44
42
 
45
- ### List Tasks
43
+ ## List Tasks
46
44
 
47
45
  ```typescript
48
46
  const result = await Ariari.tasks({
@@ -51,8 +49,6 @@ const result = await Ariari.tasks({
51
49
  order: -1
52
50
  });
53
51
 
54
-
55
52
  const nextResult = await Ariari.tasks(result.next);
56
- ...
57
53
  const prevResult = await Ariari.tasks(result.prev);
58
54
  ```
package/dist/index.d.mts CHANGED
@@ -1,3 +1,7 @@
1
+ type Config = {
2
+ projectId: string;
3
+ secretId: string;
4
+ };
1
5
  type Message = {
2
6
  phone: string[] | string;
3
7
  message: string;
@@ -10,24 +14,14 @@ type GetTaskParam = {
10
14
 
11
15
  declare class Task {
12
16
  id: string;
13
- notifTaskId: string;
14
- constructor(id: string, notifTaskId: string);
15
- status(): Promise<unknown>;
17
+ constructor(id: string);
18
+ status(): Promise<any>;
16
19
  smsDetails(): Promise<unknown>;
17
- detailedStatus(): Promise<unknown>;
18
- }
19
- declare class Notification {
20
- tasks(param: GetTaskParam): Promise<unknown>;
21
- send(...data: Message[]): Promise<Task>;
22
- sendMessage(data: Message): Promise<Task>;
23
- getMessages(param: GetTaskParam): Promise<unknown>;
24
20
  }
25
21
  declare class Ariari {
26
- private static notification;
27
- static config(config: any): void;
28
- static sendMessage(data: Message): Promise<Task>;
22
+ static config(config: Config): void;
29
23
  static send(...data: Message[]): Promise<Task>;
30
24
  static tasks(param: GetTaskParam): Promise<unknown>;
31
25
  }
32
26
 
33
- export { Ariari, type GetTaskParam, type Message, Notification, Task };
27
+ export { Ariari, type GetTaskParam, type Message, Task };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,7 @@
1
+ type Config = {
2
+ projectId: string;
3
+ secretId: string;
4
+ };
1
5
  type Message = {
2
6
  phone: string[] | string;
3
7
  message: string;
@@ -10,24 +14,14 @@ type GetTaskParam = {
10
14
 
11
15
  declare class Task {
12
16
  id: string;
13
- notifTaskId: string;
14
- constructor(id: string, notifTaskId: string);
15
- status(): Promise<unknown>;
17
+ constructor(id: string);
18
+ status(): Promise<any>;
16
19
  smsDetails(): Promise<unknown>;
17
- detailedStatus(): Promise<unknown>;
18
- }
19
- declare class Notification {
20
- tasks(param: GetTaskParam): Promise<unknown>;
21
- send(...data: Message[]): Promise<Task>;
22
- sendMessage(data: Message): Promise<Task>;
23
- getMessages(param: GetTaskParam): Promise<unknown>;
24
20
  }
25
21
  declare class Ariari {
26
- private static notification;
27
- static config(config: any): void;
28
- static sendMessage(data: Message): Promise<Task>;
22
+ static config(config: Config): void;
29
23
  static send(...data: Message[]): Promise<Task>;
30
24
  static tasks(param: GetTaskParam): Promise<unknown>;
31
25
  }
32
26
 
33
- export { Ariari, type GetTaskParam, type Message, Notification, Task };
27
+ export { Ariari, type GetTaskParam, type Message, Task };
package/dist/index.js CHANGED
@@ -21,7 +21,6 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var src_exports = {};
22
22
  __export(src_exports, {
23
23
  Ariari: () => Ariari,
24
- Notification: () => Notification,
25
24
  Task: () => Task
26
25
  });
27
26
  module.exports = __toCommonJS(src_exports);
@@ -88,25 +87,22 @@ function normalizePhoneNumber(phone) {
88
87
  return normalized;
89
88
  }
90
89
  var Task = class {
91
- constructor(id, notifTaskId) {
90
+ constructor(id) {
92
91
  this.id = id;
93
- this.notifTaskId = notifTaskId;
94
92
  }
95
93
  async status() {
96
- return httpGet(`/api/notif-task/${this.notifTaskId}/sms-details`);
94
+ const response = await httpGet(`/api/notif-task/${this.id}/sms-details`);
95
+ return response.summary;
97
96
  }
98
97
  async smsDetails() {
99
- return httpGet(`/api/notif-task/${this.notifTaskId}/sms-details`);
100
- }
101
- async detailedStatus() {
102
- return httpGet(`/api/notif-task/${this.notifTaskId}/sms-details`);
98
+ return httpGet(`/api/notif-task/${this.id}/sms-details`);
103
99
  }
104
100
  };
105
- var Notification = class {
106
- async tasks(param) {
107
- return httpGet(`/api/sms?from=${param.from}&count=${param.count}&order=${param.order}`);
101
+ var Ariari = class {
102
+ static config(config2) {
103
+ setConfig(config2);
108
104
  }
109
- async send(...data) {
105
+ static async send(...data) {
110
106
  const messages = data.map((item) => ({
111
107
  phones: (Array.isArray(item.phone) ? item.phone : [item.phone]).map(normalizePhoneNumber),
112
108
  message: item.message
@@ -118,33 +114,14 @@ var Notification = class {
118
114
  if (!response.notifTaskId) {
119
115
  throw new Error("Invalid response: no notifTaskId returned");
120
116
  }
121
- return new Task(response.data[0], response.notifTaskId);
122
- }
123
- async sendMessage(data) {
124
- return this.send(data);
125
- }
126
- async getMessages(param) {
127
- return httpGet(`/api/sms?from=${param.from}&count=${param.count}&order=${param.order}`);
128
- }
129
- };
130
- var Ariari = class {
131
- static config(config2) {
132
- setConfig(config2);
133
- }
134
- static async sendMessage(data) {
135
- return this.notification.sendMessage(data);
136
- }
137
- static async send(...data) {
138
- return this.notification.send(...data);
117
+ return new Task(response.notifTaskId);
139
118
  }
140
119
  static async tasks(param) {
141
- return this.notification.tasks(param);
120
+ return httpGet(`/api/sms?from=${param.from}&count=${param.count}&order=${param.order}`);
142
121
  }
143
122
  };
144
- Ariari.notification = new Notification();
145
123
  // Annotate the CommonJS export names for ESM import in node:
146
124
  0 && (module.exports = {
147
125
  Ariari,
148
- Notification,
149
126
  Task
150
127
  });
package/dist/index.mjs CHANGED
@@ -60,25 +60,22 @@ function normalizePhoneNumber(phone) {
60
60
  return normalized;
61
61
  }
62
62
  var Task = class {
63
- constructor(id, notifTaskId) {
63
+ constructor(id) {
64
64
  this.id = id;
65
- this.notifTaskId = notifTaskId;
66
65
  }
67
66
  async status() {
68
- return httpGet(`/api/notif-task/${this.notifTaskId}/sms-details`);
67
+ const response = await httpGet(`/api/notif-task/${this.id}/sms-details`);
68
+ return response.summary;
69
69
  }
70
70
  async smsDetails() {
71
- return httpGet(`/api/notif-task/${this.notifTaskId}/sms-details`);
72
- }
73
- async detailedStatus() {
74
- return httpGet(`/api/notif-task/${this.notifTaskId}/sms-details`);
71
+ return httpGet(`/api/notif-task/${this.id}/sms-details`);
75
72
  }
76
73
  };
77
- var Notification = class {
78
- async tasks(param) {
79
- return httpGet(`/api/sms?from=${param.from}&count=${param.count}&order=${param.order}`);
74
+ var Ariari = class {
75
+ static config(config2) {
76
+ setConfig(config2);
80
77
  }
81
- async send(...data) {
78
+ static async send(...data) {
82
79
  const messages = data.map((item) => ({
83
80
  phones: (Array.isArray(item.phone) ? item.phone : [item.phone]).map(normalizePhoneNumber),
84
81
  message: item.message
@@ -90,32 +87,13 @@ var Notification = class {
90
87
  if (!response.notifTaskId) {
91
88
  throw new Error("Invalid response: no notifTaskId returned");
92
89
  }
93
- return new Task(response.data[0], response.notifTaskId);
94
- }
95
- async sendMessage(data) {
96
- return this.send(data);
97
- }
98
- async getMessages(param) {
99
- return httpGet(`/api/sms?from=${param.from}&count=${param.count}&order=${param.order}`);
100
- }
101
- };
102
- var Ariari = class {
103
- static config(config2) {
104
- setConfig(config2);
105
- }
106
- static async sendMessage(data) {
107
- return this.notification.sendMessage(data);
108
- }
109
- static async send(...data) {
110
- return this.notification.send(...data);
90
+ return new Task(response.notifTaskId);
111
91
  }
112
92
  static async tasks(param) {
113
- return this.notification.tasks(param);
93
+ return httpGet(`/api/sms?from=${param.from}&count=${param.count}&order=${param.order}`);
114
94
  }
115
95
  };
116
- Ariari.notification = new Notification();
117
96
  export {
118
97
  Ariari,
119
- Notification,
120
98
  Task
121
99
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ariary/notification",
3
- "version": "2.0.7",
3
+ "version": "2.0.9",
4
4
  "description": "SMS et Notification Task SDK pour l'API Ariary",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",