@ariary/notification 3.0.10 → 3.0.12

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
@@ -103,32 +103,40 @@ const estimate = await Ariari.estimate(
103
103
 
104
104
  `send()` returns a `Task` object. Call `.status()` to check delivery progress.
105
105
 
106
- ### `task.status()` TaskStatus
106
+ All methods return the same response shape:
107
107
 
108
108
  | Field | Type | Description |
109
109
  |---|---|---|
110
- | `total` | number | Total SMS count |
111
- | `sent` | number | Successfully sent |
112
- | `failed` | number | Failed to send |
113
- | `delivered` | number | Confirmed delivered |
110
+ | `task` | TaskData | Task metadata (see below) |
111
+ | `sms` | SmsDetail[] | List of SMS details (`[]` when no details requested) |
112
+ | `total` | number | Total SMS count for pagination (`0` when no details requested) |
114
113
 
115
- ### `task.status(count, page?)` TaskWithDetails
114
+ | Method | Description |
115
+ |---|---|
116
+ | `task.status()` | Task only, `sms: []` |
117
+ | `task.status(count)` | Task + first `count` SMS |
118
+ | `task.status(count, page)` | Task + paginated SMS |
119
+ | `task.fullStatus()` | Task + all SMS |
120
+
121
+ ### TaskData
116
122
 
117
123
  | Field | Type | Description |
118
124
  |---|---|---|
119
- | `task` | TaskResponse | Task metadata (see below) |
120
- | `sms` | SmsDetail[] | List of SMS details |
121
- | `total` | number | Total SMS count |
125
+ | `_id` | string | Task ID |
126
+ | `status` | TaskCounters | Delivery counters per SMS |
127
+ | `statusPage` | TaskCounters | Delivery counters per SMS page |
128
+ | `projectId` | string | Project ID |
129
+ | `createdAt` | string | Creation date |
130
+ | `scheduledAt` | string? | Scheduled date (only if scheduled) |
122
131
 
123
- ### TaskResponse
132
+ ### TaskCounters
124
133
 
125
134
  | Field | Type | Description |
126
135
  |---|---|---|
127
- | `_id` | string | Task ID |
128
- | `status` | TaskStatus | Delivery counters per SMS |
129
- | `statusPage` | TaskStatus | Delivery counters per SMS page |
130
- | `createdAt` | string | Creation date |
131
- | `scheduledAt` | string? | Scheduled date |
136
+ | `total` | number | Total SMS count |
137
+ | `sent` | number | Successfully sent |
138
+ | `failed` | number | Failed to send |
139
+ | `delivered` | number | Confirmed delivered |
132
140
 
133
141
  ### SmsDetail
134
142
 
@@ -143,20 +151,20 @@ const estimate = await Ariari.estimate(
143
151
  ```ts
144
152
  const task = await Ariari.send({ phone: '0340000000', message: 'Hello!' })
145
153
 
146
- // status counters only
147
- const status = await task.status()
148
- // { total: 1, sent: 1, failed: 0, delivered: 1 }
154
+ // task only (sms: [], total: 0)
155
+ const res = await task.status()
156
+ // res.task.status => { total: 1, sent: 1, failed: 0, delivered: 0 }
149
157
 
150
- // status + all SMS details
151
- const details = await task.status(100)
152
- // { task: { _id, status, createdAt, ... }, sms: [{ smsId, phone, message, status, retryCount }], total: 1 }
158
+ // task + first 10 SMS
159
+ const details = await task.status(10)
160
+ // details.sms => [{ smsId, phone, message, status, retryCount }]
153
161
 
154
162
  // paginated: 20 per page, page 2
155
163
  const page2 = await task.status(20, 2)
156
164
 
157
- // all SMS details at once
165
+ // all SMS at once
158
166
  const full = await task.fullStatus()
159
- // { task: { ... }, sms: [...all SMS], total: 50 }
167
+ // full.sms => [...all SMS], full.total => 50
160
168
  ```
161
169
 
162
170
  SMS statuses: `SmsStatus.SCHEDULED` | `SmsStatus.PENDING` | `SmsStatus.SENT` | `SmsStatus.DELIVERED` | `SmsStatus.FAILED`
package/dist/index.d.mts CHANGED
@@ -28,17 +28,17 @@ declare enum SmsStatus {
28
28
  DELIVERED = "DELIVERED",
29
29
  FAILED = "FAILED"
30
30
  }
31
- type TaskStatus = {
31
+ type TaskCounters = {
32
32
  total: number;
33
33
  sent: number;
34
34
  failed: number;
35
35
  delivered: number;
36
36
  };
37
- type TaskResponse = {
37
+ type TaskData = {
38
38
  _id: string;
39
39
  projectId: string;
40
- status: TaskStatus;
41
- statusPage: TaskStatus;
40
+ status: TaskCounters;
41
+ statusPage: TaskCounters;
42
42
  createdAt: string;
43
43
  scheduledAt?: string;
44
44
  };
@@ -49,8 +49,8 @@ type SmsDetail = {
49
49
  status: SmsStatus;
50
50
  retryCount: number;
51
51
  };
52
- type TaskWithDetails = {
53
- task: TaskResponse;
52
+ type TaskResponse = {
53
+ task: TaskData;
54
54
  sms: SmsDetail[];
55
55
  total: number;
56
56
  };
@@ -67,9 +67,9 @@ declare class Task {
67
67
  id: string;
68
68
  private _requester;
69
69
  constructor(id: string, requester: ReturnType<typeof createRequester>);
70
- status(): Promise<TaskStatus>;
71
- status(count: number, page?: number): Promise<TaskWithDetails>;
72
- fullStatus(): Promise<TaskWithDetails>;
70
+ status(): Promise<TaskResponse>;
71
+ status(count: number, page?: number): Promise<TaskResponse>;
72
+ fullStatus(): Promise<TaskResponse>;
73
73
  }
74
74
  declare class Ariari {
75
75
  private _config;
package/dist/index.d.ts CHANGED
@@ -28,17 +28,17 @@ declare enum SmsStatus {
28
28
  DELIVERED = "DELIVERED",
29
29
  FAILED = "FAILED"
30
30
  }
31
- type TaskStatus = {
31
+ type TaskCounters = {
32
32
  total: number;
33
33
  sent: number;
34
34
  failed: number;
35
35
  delivered: number;
36
36
  };
37
- type TaskResponse = {
37
+ type TaskData = {
38
38
  _id: string;
39
39
  projectId: string;
40
- status: TaskStatus;
41
- statusPage: TaskStatus;
40
+ status: TaskCounters;
41
+ statusPage: TaskCounters;
42
42
  createdAt: string;
43
43
  scheduledAt?: string;
44
44
  };
@@ -49,8 +49,8 @@ type SmsDetail = {
49
49
  status: SmsStatus;
50
50
  retryCount: number;
51
51
  };
52
- type TaskWithDetails = {
53
- task: TaskResponse;
52
+ type TaskResponse = {
53
+ task: TaskData;
54
54
  sms: SmsDetail[];
55
55
  total: number;
56
56
  };
@@ -67,9 +67,9 @@ declare class Task {
67
67
  id: string;
68
68
  private _requester;
69
69
  constructor(id: string, requester: ReturnType<typeof createRequester>);
70
- status(): Promise<TaskStatus>;
71
- status(count: number, page?: number): Promise<TaskWithDetails>;
72
- fullStatus(): Promise<TaskWithDetails>;
70
+ status(): Promise<TaskResponse>;
71
+ status(count: number, page?: number): Promise<TaskResponse>;
72
+ fullStatus(): Promise<TaskResponse>;
73
73
  }
74
74
  declare class Ariari {
75
75
  private _config;
package/dist/index.js CHANGED
@@ -98,12 +98,12 @@ var Task = class {
98
98
  }
99
99
  async status(count, page) {
100
100
  if (count === void 0) {
101
- const response = await this._requester.get(`/api/notif-task/${this.id}`);
102
- return response.status;
101
+ return this._requester.get(`/api/notif-task/${this.id}`);
103
102
  }
104
103
  const details = `${count},${page || 1}`;
105
104
  return this._requester.get(`/api/notif-task/${this.id}?details=${details}`);
106
105
  }
106
+ // All SMS at once
107
107
  async fullStatus() {
108
108
  return this._requester.get(`/api/notif-task/${this.id}?details=-1`);
109
109
  }
package/dist/index.mjs CHANGED
@@ -71,12 +71,12 @@ var Task = class {
71
71
  }
72
72
  async status(count, page) {
73
73
  if (count === void 0) {
74
- const response = await this._requester.get(`/api/notif-task/${this.id}`);
75
- return response.status;
74
+ return this._requester.get(`/api/notif-task/${this.id}`);
76
75
  }
77
76
  const details = `${count},${page || 1}`;
78
77
  return this._requester.get(`/api/notif-task/${this.id}?details=${details}`);
79
78
  }
79
+ // All SMS at once
80
80
  async fullStatus() {
81
81
  return this._requester.get(`/api/notif-task/${this.id}?details=-1`);
82
82
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ariary/notification",
3
- "version": "3.0.10",
3
+ "version": "3.0.12",
4
4
  "description": "Ariary SMS & Notification SDK (ariari.mg) — Send SMS in Madagascar with automatic phone normalization, bulk messaging, deferred/scheduled sending, delivery tracking, credit estimation. Supports Orange, Airtel, Telma. Multi-instance, TypeScript-first.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",