@ariary/notification 2.0.6 → 2.0.8

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);
17
+ constructor(id: string);
15
18
  status(): Promise<unknown>;
16
19
  smsDetails(): Promise<unknown>;
17
- detailedStatus(): Promise<unknown>;
18
- }
19
- declare class Notification {
20
- tasks(param: GetTaskParam): void;
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
- static tasks(param: GetTaskParam): Promise<void>;
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);
17
+ constructor(id: string);
15
18
  status(): Promise<unknown>;
16
19
  smsDetails(): Promise<unknown>;
17
- detailedStatus(): Promise<unknown>;
18
- }
19
- declare class Notification {
20
- tasks(param: GetTaskParam): void;
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
- static tasks(param: GetTaskParam): Promise<void>;
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,21 @@ 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
+ return httpGet(`/api/notif-task/${this.id}/sms-details`);
97
95
  }
98
96
  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`);
97
+ return httpGet(`/api/notif-task/${this.id}/sms-details`);
103
98
  }
104
99
  };
105
- var Notification = class {
106
- tasks(param) {
107
- throw new Error("Method not implemented.");
100
+ var Ariari = class {
101
+ static config(config2) {
102
+ setConfig(config2);
108
103
  }
109
- async send(...data) {
104
+ static async send(...data) {
110
105
  const messages = data.map((item) => ({
111
106
  phones: (Array.isArray(item.phone) ? item.phone : [item.phone]).map(normalizePhoneNumber),
112
107
  message: item.message
@@ -118,33 +113,14 @@ var Notification = class {
118
113
  if (!response.notifTaskId) {
119
114
  throw new Error("Invalid response: no notifTaskId returned");
120
115
  }
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);
116
+ return new Task(response.notifTaskId);
139
117
  }
140
118
  static async tasks(param) {
141
- return this.notification.tasks(param);
119
+ return httpGet(`/api/sms?from=${param.from}&count=${param.count}&order=${param.order}`);
142
120
  }
143
121
  };
144
- Ariari.notification = new Notification();
145
122
  // Annotate the CommonJS export names for ESM import in node:
146
123
  0 && (module.exports = {
147
124
  Ariari,
148
- Notification,
149
125
  Task
150
126
  });
package/dist/index.mjs CHANGED
@@ -60,25 +60,21 @@ 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
+ return httpGet(`/api/notif-task/${this.id}/sms-details`);
69
68
  }
70
69
  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`);
70
+ return httpGet(`/api/notif-task/${this.id}/sms-details`);
75
71
  }
76
72
  };
77
- var Notification = class {
78
- tasks(param) {
79
- throw new Error("Method not implemented.");
73
+ var Ariari = class {
74
+ static config(config2) {
75
+ setConfig(config2);
80
76
  }
81
- async send(...data) {
77
+ static async send(...data) {
82
78
  const messages = data.map((item) => ({
83
79
  phones: (Array.isArray(item.phone) ? item.phone : [item.phone]).map(normalizePhoneNumber),
84
80
  message: item.message
@@ -90,32 +86,13 @@ var Notification = class {
90
86
  if (!response.notifTaskId) {
91
87
  throw new Error("Invalid response: no notifTaskId returned");
92
88
  }
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);
89
+ return new Task(response.notifTaskId);
111
90
  }
112
91
  static async tasks(param) {
113
- return this.notification.tasks(param);
92
+ return httpGet(`/api/sms?from=${param.from}&count=${param.count}&order=${param.order}`);
114
93
  }
115
94
  };
116
- Ariari.notification = new Notification();
117
95
  export {
118
96
  Ariari,
119
- Notification,
120
97
  Task
121
98
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ariary/notification",
3
- "version": "2.0.6",
3
+ "version": "2.0.8",
4
4
  "description": "SMS et Notification Task SDK pour l'API Ariary",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",