@ariary/notification 3.0.4 → 3.0.6
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 +58 -1
- package/dist/index.d.mts +8 -2
- package/dist/index.d.ts +8 -2
- package/dist/index.js +16 -1
- package/dist/index.mjs +12 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -23,6 +23,19 @@ Ariari.config({
|
|
|
23
23
|
|
|
24
24
|
`Ariari.send()` accepts one or more messages. Phone numbers are automatically normalized (`+261340000000`, `261340000000`, `0340000000` all work).
|
|
25
25
|
|
|
26
|
+
Each message has the following shape:
|
|
27
|
+
|
|
28
|
+
| Field | Type | Required | Description |
|
|
29
|
+
|---|---|---|---|
|
|
30
|
+
| `phone` | string \| string[] | Yes | Recipient phone number(s) |
|
|
31
|
+
| `message` | string | Yes | SMS content |
|
|
32
|
+
|
|
33
|
+
You can also pass a `SendOptions` object as the first argument:
|
|
34
|
+
|
|
35
|
+
| Field | Type | Required | Description |
|
|
36
|
+
|---|---|---|---|
|
|
37
|
+
| `scheduledAt` | string | No | ISO date to schedule the SMS |
|
|
38
|
+
|
|
26
39
|
```ts
|
|
27
40
|
// single recipient
|
|
28
41
|
const task = await Ariari.send({ phone: '0340000000', message: 'Hello!' })
|
|
@@ -41,6 +54,42 @@ const task = await Ariari.send(
|
|
|
41
54
|
|
|
42
55
|
`send()` returns a `Task` object. Call `.status()` to check delivery progress.
|
|
43
56
|
|
|
57
|
+
### `task.status()` — TaskStatus
|
|
58
|
+
|
|
59
|
+
| Field | Type | Description |
|
|
60
|
+
|---|---|---|
|
|
61
|
+
| `total` | number | Total SMS count |
|
|
62
|
+
| `sent` | number | Successfully sent |
|
|
63
|
+
| `failed` | number | Failed to send |
|
|
64
|
+
| `delivered` | number | Confirmed delivered |
|
|
65
|
+
|
|
66
|
+
### `task.status(count, page?)` — TaskWithDetails
|
|
67
|
+
|
|
68
|
+
| Field | Type | Description |
|
|
69
|
+
|---|---|---|
|
|
70
|
+
| `task` | TaskResponse | Task metadata (see below) |
|
|
71
|
+
| `sms` | SmsDetail[] | List of SMS details |
|
|
72
|
+
| `total` | number | Total SMS count |
|
|
73
|
+
|
|
74
|
+
### TaskResponse
|
|
75
|
+
|
|
76
|
+
| Field | Type | Description |
|
|
77
|
+
|---|---|---|
|
|
78
|
+
| `_id` | string | Task ID |
|
|
79
|
+
| `status` | TaskStatus | Delivery counters |
|
|
80
|
+
| `createdAt` | string | Creation date |
|
|
81
|
+
| `scheduledAt` | string? | Scheduled date |
|
|
82
|
+
|
|
83
|
+
### SmsDetail
|
|
84
|
+
|
|
85
|
+
| Field | Type | Description |
|
|
86
|
+
|---|---|---|
|
|
87
|
+
| `smsId` | string | SMS ID |
|
|
88
|
+
| `phone` | string | Recipient phone number |
|
|
89
|
+
| `message` | string | SMS content |
|
|
90
|
+
| `status` | SmsStatus | `SCHEDULED` \| `PENDING` \| `SENT` \| `DELIVERED` \| `FAILED` |
|
|
91
|
+
| `retryCount` | number | Number of retry attempts |
|
|
92
|
+
|
|
44
93
|
```ts
|
|
45
94
|
const task = await Ariari.send({ phone: '0340000000', message: 'Hello!' })
|
|
46
95
|
|
|
@@ -56,7 +105,15 @@ const details = await task.status(100)
|
|
|
56
105
|
const page2 = await task.status(20, 2)
|
|
57
106
|
```
|
|
58
107
|
|
|
59
|
-
SMS statuses: `SCHEDULED` | `PENDING` | `SENT` | `DELIVERED` | `FAILED`
|
|
108
|
+
SMS statuses: `SmsStatus.SCHEDULED` | `SmsStatus.PENDING` | `SmsStatus.SENT` | `SmsStatus.DELIVERED` | `SmsStatus.FAILED`
|
|
109
|
+
|
|
110
|
+
A `SmsStatus` enum is also exported:
|
|
111
|
+
|
|
112
|
+
```ts
|
|
113
|
+
import { SmsStatus } from '@ariary/notification'
|
|
114
|
+
|
|
115
|
+
if (sms.status === SmsStatus.DELIVERED) { ... }
|
|
116
|
+
```
|
|
60
117
|
|
|
61
118
|
## Retrieve an existing Task
|
|
62
119
|
|
package/dist/index.d.mts
CHANGED
|
@@ -24,7 +24,13 @@ type Message = {
|
|
|
24
24
|
type SendOptions = {
|
|
25
25
|
scheduledAt?: string;
|
|
26
26
|
};
|
|
27
|
-
|
|
27
|
+
declare enum SmsStatus {
|
|
28
|
+
SCHEDULED = "SCHEDULED",
|
|
29
|
+
PENDING = "PENDING",
|
|
30
|
+
SENT = "SENT",
|
|
31
|
+
DELIVERED = "DELIVERED",
|
|
32
|
+
FAILED = "FAILED"
|
|
33
|
+
}
|
|
28
34
|
type TaskStatus = {
|
|
29
35
|
total: number;
|
|
30
36
|
sent: number;
|
|
@@ -76,4 +82,4 @@ declare class Ariari {
|
|
|
76
82
|
static getTask: (taskId: string) => Promise<Task>;
|
|
77
83
|
}
|
|
78
84
|
|
|
79
|
-
export { Ariari as default };
|
|
85
|
+
export { SmsStatus, Ariari as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -24,7 +24,13 @@ type Message = {
|
|
|
24
24
|
type SendOptions = {
|
|
25
25
|
scheduledAt?: string;
|
|
26
26
|
};
|
|
27
|
-
|
|
27
|
+
declare enum SmsStatus {
|
|
28
|
+
SCHEDULED = "SCHEDULED",
|
|
29
|
+
PENDING = "PENDING",
|
|
30
|
+
SENT = "SENT",
|
|
31
|
+
DELIVERED = "DELIVERED",
|
|
32
|
+
FAILED = "FAILED"
|
|
33
|
+
}
|
|
28
34
|
type TaskStatus = {
|
|
29
35
|
total: number;
|
|
30
36
|
sent: number;
|
|
@@ -76,4 +82,4 @@ declare class Ariari {
|
|
|
76
82
|
static getTask: (taskId: string) => Promise<Task>;
|
|
77
83
|
}
|
|
78
84
|
|
|
79
|
-
export { Ariari as default };
|
|
85
|
+
export { SmsStatus, Ariari as default };
|
package/dist/index.js
CHANGED
|
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var src_exports = {};
|
|
22
22
|
__export(src_exports, {
|
|
23
|
+
SmsStatus: () => SmsStatus,
|
|
23
24
|
default: () => src_default
|
|
24
25
|
});
|
|
25
26
|
module.exports = __toCommonJS(src_exports);
|
|
@@ -27,7 +28,7 @@ module.exports = __toCommonJS(src_exports);
|
|
|
27
28
|
// ../common/http.ts
|
|
28
29
|
async function request(verb, endpoint, options, config) {
|
|
29
30
|
if (!config) throw new Error("Ariari package not configured.");
|
|
30
|
-
const url = `${config.baseUrl || "https://
|
|
31
|
+
const url = `${config.baseUrl || "https://api.ariari.mg"}${endpoint}`;
|
|
31
32
|
const headers = { "Content-Type": "application/json" };
|
|
32
33
|
if (!options.public) {
|
|
33
34
|
headers["x-project-id"] = config.projectId;
|
|
@@ -67,6 +68,16 @@ var normalizePhoneNumber = (phone) => {
|
|
|
67
68
|
return normalized;
|
|
68
69
|
};
|
|
69
70
|
|
|
71
|
+
// src/types/index.ts
|
|
72
|
+
var SmsStatus = /* @__PURE__ */ ((SmsStatus2) => {
|
|
73
|
+
SmsStatus2["SCHEDULED"] = "SCHEDULED";
|
|
74
|
+
SmsStatus2["PENDING"] = "PENDING";
|
|
75
|
+
SmsStatus2["SENT"] = "SENT";
|
|
76
|
+
SmsStatus2["DELIVERED"] = "DELIVERED";
|
|
77
|
+
SmsStatus2["FAILED"] = "FAILED";
|
|
78
|
+
return SmsStatus2;
|
|
79
|
+
})(SmsStatus || {});
|
|
80
|
+
|
|
70
81
|
// src/index.ts
|
|
71
82
|
var instances = {};
|
|
72
83
|
var Task = class {
|
|
@@ -115,3 +126,7 @@ _Ariari.send = async (...args) => await _Ariari.get("main")?.send(...args);
|
|
|
115
126
|
_Ariari.getTask = async (taskId) => _Ariari.get("main")?.getTask(taskId);
|
|
116
127
|
var Ariari = _Ariari;
|
|
117
128
|
var src_default = Ariari;
|
|
129
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
130
|
+
0 && (module.exports = {
|
|
131
|
+
SmsStatus
|
|
132
|
+
});
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// ../common/http.ts
|
|
2
2
|
async function request(verb, endpoint, options, config) {
|
|
3
3
|
if (!config) throw new Error("Ariari package not configured.");
|
|
4
|
-
const url = `${config.baseUrl || "https://
|
|
4
|
+
const url = `${config.baseUrl || "https://api.ariari.mg"}${endpoint}`;
|
|
5
5
|
const headers = { "Content-Type": "application/json" };
|
|
6
6
|
if (!options.public) {
|
|
7
7
|
headers["x-project-id"] = config.projectId;
|
|
@@ -41,6 +41,16 @@ var normalizePhoneNumber = (phone) => {
|
|
|
41
41
|
return normalized;
|
|
42
42
|
};
|
|
43
43
|
|
|
44
|
+
// src/types/index.ts
|
|
45
|
+
var SmsStatus = /* @__PURE__ */ ((SmsStatus2) => {
|
|
46
|
+
SmsStatus2["SCHEDULED"] = "SCHEDULED";
|
|
47
|
+
SmsStatus2["PENDING"] = "PENDING";
|
|
48
|
+
SmsStatus2["SENT"] = "SENT";
|
|
49
|
+
SmsStatus2["DELIVERED"] = "DELIVERED";
|
|
50
|
+
SmsStatus2["FAILED"] = "FAILED";
|
|
51
|
+
return SmsStatus2;
|
|
52
|
+
})(SmsStatus || {});
|
|
53
|
+
|
|
44
54
|
// src/index.ts
|
|
45
55
|
var instances = {};
|
|
46
56
|
var Task = class {
|
|
@@ -90,5 +100,6 @@ _Ariari.getTask = async (taskId) => _Ariari.get("main")?.getTask(taskId);
|
|
|
90
100
|
var Ariari = _Ariari;
|
|
91
101
|
var src_default = Ariari;
|
|
92
102
|
export {
|
|
103
|
+
SmsStatus,
|
|
93
104
|
src_default as default
|
|
94
105
|
};
|