@ariary/notification 1.0.9 → 2.0.1
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 +4 -5
- package/dist/index.js +10 -3
- package/dist/index.mjs +10 -3
- package/package.json +1 -1
- package/dist/index.d.mts +0 -30
- package/dist/index.d.ts +0 -30
package/README.md
CHANGED
|
@@ -28,9 +28,6 @@ const task = await Ariari.send(
|
|
|
28
28
|
{ phone: '+261123456789', message: 'Message 1' },
|
|
29
29
|
{ phone: ['+261987654321', '+261555555555'], message: 'Message 2' }
|
|
30
30
|
);
|
|
31
|
-
|
|
32
|
-
// Check task status
|
|
33
|
-
await task.status();
|
|
34
31
|
```
|
|
35
32
|
|
|
36
33
|
### Check Task Status
|
|
@@ -39,10 +36,12 @@ You can also check the status of a task by ID:
|
|
|
39
36
|
|
|
40
37
|
```typescript
|
|
41
38
|
const task = new Ariari.Task('task-id-123');
|
|
42
|
-
await task.status();
|
|
43
|
-
await task.detailedStatus();
|
|
39
|
+
const status = await task.status();
|
|
40
|
+
const detailedStatus = await task.detailedStatus();
|
|
44
41
|
```
|
|
45
42
|
|
|
43
|
+
The status endpoint returns SMS details including status (SENT, PENDING, FAILED), retry count, and summary information.
|
|
44
|
+
|
|
46
45
|
### List Tasks
|
|
47
46
|
|
|
48
47
|
```typescript
|
package/dist/index.js
CHANGED
|
@@ -80,21 +80,28 @@ async function httpPost(endpoint, body, requiresSecret = true) {
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
// src/index.ts
|
|
83
|
+
function normalizePhoneNumber(phone) {
|
|
84
|
+
let normalized = phone.replace(/\D/g, "");
|
|
85
|
+
if (normalized.startsWith("261")) {
|
|
86
|
+
normalized = "0" + normalized.slice(3);
|
|
87
|
+
}
|
|
88
|
+
return normalized;
|
|
89
|
+
}
|
|
83
90
|
var Task = class {
|
|
84
91
|
constructor(id) {
|
|
85
92
|
this.id = id;
|
|
86
93
|
}
|
|
87
94
|
async status() {
|
|
88
|
-
return httpGet(`/api/
|
|
95
|
+
return httpGet(`/api/notif-task/${this.id}/sms-details`);
|
|
89
96
|
}
|
|
90
97
|
async detailedStatus() {
|
|
91
|
-
return httpGet(`/api/
|
|
98
|
+
return httpGet(`/api/notif-task/${this.id}/sms-details`);
|
|
92
99
|
}
|
|
93
100
|
};
|
|
94
101
|
var Notification = class {
|
|
95
102
|
async send(...data) {
|
|
96
103
|
const messages = data.map((item) => ({
|
|
97
|
-
phones: Array.isArray(item.phone) ? item.phone : [item.phone],
|
|
104
|
+
phones: (Array.isArray(item.phone) ? item.phone : [item.phone]).map(normalizePhoneNumber),
|
|
98
105
|
message: item.message
|
|
99
106
|
}));
|
|
100
107
|
const response = await httpPost("/api/sms/bulk", { messages });
|
package/dist/index.mjs
CHANGED
|
@@ -52,21 +52,28 @@ async function httpPost(endpoint, body, requiresSecret = true) {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
// src/index.ts
|
|
55
|
+
function normalizePhoneNumber(phone) {
|
|
56
|
+
let normalized = phone.replace(/\D/g, "");
|
|
57
|
+
if (normalized.startsWith("261")) {
|
|
58
|
+
normalized = "0" + normalized.slice(3);
|
|
59
|
+
}
|
|
60
|
+
return normalized;
|
|
61
|
+
}
|
|
55
62
|
var Task = class {
|
|
56
63
|
constructor(id) {
|
|
57
64
|
this.id = id;
|
|
58
65
|
}
|
|
59
66
|
async status() {
|
|
60
|
-
return httpGet(`/api/
|
|
67
|
+
return httpGet(`/api/notif-task/${this.id}/sms-details`);
|
|
61
68
|
}
|
|
62
69
|
async detailedStatus() {
|
|
63
|
-
return httpGet(`/api/
|
|
70
|
+
return httpGet(`/api/notif-task/${this.id}/sms-details`);
|
|
64
71
|
}
|
|
65
72
|
};
|
|
66
73
|
var Notification = class {
|
|
67
74
|
async send(...data) {
|
|
68
75
|
const messages = data.map((item) => ({
|
|
69
|
-
phones: Array.isArray(item.phone) ? item.phone : [item.phone],
|
|
76
|
+
phones: (Array.isArray(item.phone) ? item.phone : [item.phone]).map(normalizePhoneNumber),
|
|
70
77
|
message: item.message
|
|
71
78
|
}));
|
|
72
79
|
const response = await httpPost("/api/sms/bulk", { messages });
|
package/package.json
CHANGED
package/dist/index.d.mts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
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
|
-
constructor(id: string);
|
|
14
|
-
status(): Promise<unknown>;
|
|
15
|
-
detailedStatus(): Promise<unknown>;
|
|
16
|
-
}
|
|
17
|
-
declare class Notification {
|
|
18
|
-
send(...data: Message[]): Promise<Task>;
|
|
19
|
-
sendMessage(data: Message): Promise<Task>;
|
|
20
|
-
getMessages(param: GetTaskParam): Promise<unknown>;
|
|
21
|
-
}
|
|
22
|
-
declare class Ariari {
|
|
23
|
-
private static notification;
|
|
24
|
-
static config(config: any): void;
|
|
25
|
-
static sendMessage(data: Message): Promise<Task>;
|
|
26
|
-
static send(...data: Message[]): Promise<Task>;
|
|
27
|
-
static getMessages(param: GetTaskParam): Promise<unknown>;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export { Ariari, type GetTaskParam, type Message, Notification, Task };
|
package/dist/index.d.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
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
|
-
constructor(id: string);
|
|
14
|
-
status(): Promise<unknown>;
|
|
15
|
-
detailedStatus(): Promise<unknown>;
|
|
16
|
-
}
|
|
17
|
-
declare class Notification {
|
|
18
|
-
send(...data: Message[]): Promise<Task>;
|
|
19
|
-
sendMessage(data: Message): Promise<Task>;
|
|
20
|
-
getMessages(param: GetTaskParam): Promise<unknown>;
|
|
21
|
-
}
|
|
22
|
-
declare class Ariari {
|
|
23
|
-
private static notification;
|
|
24
|
-
static config(config: any): void;
|
|
25
|
-
static sendMessage(data: Message): Promise<Task>;
|
|
26
|
-
static send(...data: Message[]): Promise<Task>;
|
|
27
|
-
static getMessages(param: GetTaskParam): Promise<unknown>;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export { Ariari, type GetTaskParam, type Message, Notification, Task };
|