@ariary/notification 2.0.1 → 2.0.3
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 +14 -4
- package/dist/index.d.mts +31 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.js +8 -4
- package/dist/index.mjs +8 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -32,15 +32,25 @@ const task = await Ariari.send(
|
|
|
32
32
|
|
|
33
33
|
### Check Task Status
|
|
34
34
|
|
|
35
|
-
You can
|
|
35
|
+
You can check the status of a task:
|
|
36
36
|
|
|
37
37
|
```typescript
|
|
38
|
-
const task =
|
|
38
|
+
const task = await Ariari.send(
|
|
39
|
+
{ phone: '+261123456789', message: 'Message 1' },
|
|
40
|
+
{ phone: ['+261987654321', '+261555555555'], message: 'Message 2' }
|
|
41
|
+
);
|
|
42
|
+
|
|
39
43
|
const status = await task.status();
|
|
40
|
-
|
|
44
|
+
console.log(status);
|
|
45
|
+
// Returns SMS details: status (PENDING, SENT, FAILED), retry count, summary
|
|
41
46
|
```
|
|
42
47
|
|
|
43
|
-
|
|
48
|
+
Or check an existing task by ID:
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
const task = new Ariari.Task( 'id');
|
|
52
|
+
const status = await task.status();
|
|
53
|
+
```
|
|
44
54
|
|
|
45
55
|
### List Tasks
|
|
46
56
|
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
type Message = {
|
|
2
|
+
phone: string[] | string;
|
|
3
|
+
message: string;
|
|
4
|
+
};
|
|
5
|
+
type GetTaskParam = {
|
|
6
|
+
from: number;
|
|
7
|
+
count: number;
|
|
8
|
+
order: -1 | 1;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
declare class Task {
|
|
12
|
+
id: string;
|
|
13
|
+
notifTaskId: string;
|
|
14
|
+
constructor(id: string, notifTaskId: string);
|
|
15
|
+
status(): Promise<unknown>;
|
|
16
|
+
detailedStatus(): Promise<unknown>;
|
|
17
|
+
}
|
|
18
|
+
declare class Notification {
|
|
19
|
+
send(...data: Message[]): Promise<Task>;
|
|
20
|
+
sendMessage(data: Message): Promise<Task>;
|
|
21
|
+
getMessages(param: GetTaskParam): Promise<unknown>;
|
|
22
|
+
}
|
|
23
|
+
declare class Ariari {
|
|
24
|
+
private static notification;
|
|
25
|
+
static config(config: any): void;
|
|
26
|
+
static sendMessage(data: Message): Promise<Task>;
|
|
27
|
+
static send(...data: Message[]): Promise<Task>;
|
|
28
|
+
static getMessages(param: GetTaskParam): Promise<unknown>;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export { Ariari, type GetTaskParam, type Message, Notification, Task };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
type Message = {
|
|
2
|
+
phone: string[] | string;
|
|
3
|
+
message: string;
|
|
4
|
+
};
|
|
5
|
+
type GetTaskParam = {
|
|
6
|
+
from: number;
|
|
7
|
+
count: number;
|
|
8
|
+
order: -1 | 1;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
declare class Task {
|
|
12
|
+
id: string;
|
|
13
|
+
notifTaskId: string;
|
|
14
|
+
constructor(id: string, notifTaskId: string);
|
|
15
|
+
status(): Promise<unknown>;
|
|
16
|
+
detailedStatus(): Promise<unknown>;
|
|
17
|
+
}
|
|
18
|
+
declare class Notification {
|
|
19
|
+
send(...data: Message[]): Promise<Task>;
|
|
20
|
+
sendMessage(data: Message): Promise<Task>;
|
|
21
|
+
getMessages(param: GetTaskParam): Promise<unknown>;
|
|
22
|
+
}
|
|
23
|
+
declare class Ariari {
|
|
24
|
+
private static notification;
|
|
25
|
+
static config(config: any): void;
|
|
26
|
+
static sendMessage(data: Message): Promise<Task>;
|
|
27
|
+
static send(...data: Message[]): Promise<Task>;
|
|
28
|
+
static getMessages(param: GetTaskParam): Promise<unknown>;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export { Ariari, type GetTaskParam, type Message, Notification, Task };
|
package/dist/index.js
CHANGED
|
@@ -88,14 +88,15 @@ function normalizePhoneNumber(phone) {
|
|
|
88
88
|
return normalized;
|
|
89
89
|
}
|
|
90
90
|
var Task = class {
|
|
91
|
-
constructor(id) {
|
|
91
|
+
constructor(id, notifTaskId) {
|
|
92
92
|
this.id = id;
|
|
93
|
+
this.notifTaskId = notifTaskId;
|
|
93
94
|
}
|
|
94
95
|
async status() {
|
|
95
|
-
return httpGet(`/api/notif-task/${this.
|
|
96
|
+
return httpGet(`/api/notif-task/${this.notifTaskId}/sms-details`);
|
|
96
97
|
}
|
|
97
98
|
async detailedStatus() {
|
|
98
|
-
return httpGet(`/api/notif-task/${this.
|
|
99
|
+
return httpGet(`/api/notif-task/${this.notifTaskId}/sms-details`);
|
|
99
100
|
}
|
|
100
101
|
};
|
|
101
102
|
var Notification = class {
|
|
@@ -108,7 +109,10 @@ var Notification = class {
|
|
|
108
109
|
if (!response.data || !Array.isArray(response.data) || response.data.length === 0) {
|
|
109
110
|
throw new Error("Invalid response: no SMS IDs returned");
|
|
110
111
|
}
|
|
111
|
-
|
|
112
|
+
if (!response.notifTaskId) {
|
|
113
|
+
throw new Error("Invalid response: no notifTaskId returned");
|
|
114
|
+
}
|
|
115
|
+
return new Task(response.data[0], response.notifTaskId);
|
|
112
116
|
}
|
|
113
117
|
async sendMessage(data) {
|
|
114
118
|
return this.send(data);
|
package/dist/index.mjs
CHANGED
|
@@ -60,14 +60,15 @@ function normalizePhoneNumber(phone) {
|
|
|
60
60
|
return normalized;
|
|
61
61
|
}
|
|
62
62
|
var Task = class {
|
|
63
|
-
constructor(id) {
|
|
63
|
+
constructor(id, notifTaskId) {
|
|
64
64
|
this.id = id;
|
|
65
|
+
this.notifTaskId = notifTaskId;
|
|
65
66
|
}
|
|
66
67
|
async status() {
|
|
67
|
-
return httpGet(`/api/notif-task/${this.
|
|
68
|
+
return httpGet(`/api/notif-task/${this.notifTaskId}/sms-details`);
|
|
68
69
|
}
|
|
69
70
|
async detailedStatus() {
|
|
70
|
-
return httpGet(`/api/notif-task/${this.
|
|
71
|
+
return httpGet(`/api/notif-task/${this.notifTaskId}/sms-details`);
|
|
71
72
|
}
|
|
72
73
|
};
|
|
73
74
|
var Notification = class {
|
|
@@ -80,7 +81,10 @@ var Notification = class {
|
|
|
80
81
|
if (!response.data || !Array.isArray(response.data) || response.data.length === 0) {
|
|
81
82
|
throw new Error("Invalid response: no SMS IDs returned");
|
|
82
83
|
}
|
|
83
|
-
|
|
84
|
+
if (!response.notifTaskId) {
|
|
85
|
+
throw new Error("Invalid response: no notifTaskId returned");
|
|
86
|
+
}
|
|
87
|
+
return new Task(response.data[0], response.notifTaskId);
|
|
84
88
|
}
|
|
85
89
|
async sendMessage(data) {
|
|
86
90
|
return this.send(data);
|