@ariary/notification 3.0.3 → 3.0.5

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
@@ -56,7 +56,15 @@ const details = await task.status(100)
56
56
  const page2 = await task.status(20, 2)
57
57
  ```
58
58
 
59
- SMS statuses: `SCHEDULED` | `PENDING` | `SENT` | `DELIVERED` | `FAILED`
59
+ SMS statuses: `SmsStatus.SCHEDULED` | `SmsStatus.PENDING` | `SmsStatus.SENT` | `SmsStatus.DELIVERED` | `SmsStatus.FAILED`
60
+
61
+ A `SmsStatus` enum is also exported:
62
+
63
+ ```ts
64
+ import { SmsStatus } from '@ariary/notification'
65
+
66
+ if (sms.status === SmsStatus.DELIVERED) { ... }
67
+ ```
60
68
 
61
69
  ## Retrieve an existing Task
62
70
 
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  type Data = {
2
- body?: Record<string, any>;
3
- params?: Record<string, any>;
2
+ body?: Record<string, unknown>;
3
+ params?: Record<string, string>;
4
4
  public?: boolean;
5
5
  };
6
6
  type PData = Omit<Data, 'body'>;
@@ -10,11 +10,11 @@ type Config = {
10
10
  baseUrl?: string;
11
11
  };
12
12
  declare const createRequester: (config: Config) => {
13
- get: <T = any>(url: string, data?: PData) => Promise<T>;
14
- post: <T = any>(url: string, data?: Data) => Promise<T>;
15
- patch: <T = any>(url: string, data?: Data) => Promise<T>;
16
- put: <T = any>(url: string, data?: Data) => Promise<T>;
17
- delete: <T = any>(url: string, data?: PData) => Promise<T>;
13
+ get: <T>(url: string, data?: PData) => Promise<T>;
14
+ post: <T>(url: string, data?: Data) => Promise<T>;
15
+ patch: <T>(url: string, data?: Data) => Promise<T>;
16
+ put: <T>(url: string, data?: Data) => Promise<T>;
17
+ delete: <T = void>(url: string, data?: PData) => Promise<T>;
18
18
  };
19
19
 
20
20
  type Message = {
@@ -24,7 +24,13 @@ type Message = {
24
24
  type SendOptions = {
25
25
  scheduledAt?: string;
26
26
  };
27
- type SmsStatus = 'SCHEDULED' | 'PENDING' | 'SENT' | 'DELIVERED' | 'FAILED';
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;
@@ -35,6 +41,7 @@ type TaskResponse = {
35
41
  _id: string;
36
42
  projectId: string;
37
43
  status: TaskStatus;
44
+ statusPage: TaskStatus;
38
45
  createdAt: string;
39
46
  scheduledAt?: string;
40
47
  };
@@ -75,4 +82,4 @@ declare class Ariari {
75
82
  static getTask: (taskId: string) => Promise<Task>;
76
83
  }
77
84
 
78
- export { Ariari as default };
85
+ export { SmsStatus, Ariari as default };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  type Data = {
2
- body?: Record<string, any>;
3
- params?: Record<string, any>;
2
+ body?: Record<string, unknown>;
3
+ params?: Record<string, string>;
4
4
  public?: boolean;
5
5
  };
6
6
  type PData = Omit<Data, 'body'>;
@@ -10,11 +10,11 @@ type Config = {
10
10
  baseUrl?: string;
11
11
  };
12
12
  declare const createRequester: (config: Config) => {
13
- get: <T = any>(url: string, data?: PData) => Promise<T>;
14
- post: <T = any>(url: string, data?: Data) => Promise<T>;
15
- patch: <T = any>(url: string, data?: Data) => Promise<T>;
16
- put: <T = any>(url: string, data?: Data) => Promise<T>;
17
- delete: <T = any>(url: string, data?: PData) => Promise<T>;
13
+ get: <T>(url: string, data?: PData) => Promise<T>;
14
+ post: <T>(url: string, data?: Data) => Promise<T>;
15
+ patch: <T>(url: string, data?: Data) => Promise<T>;
16
+ put: <T>(url: string, data?: Data) => Promise<T>;
17
+ delete: <T = void>(url: string, data?: PData) => Promise<T>;
18
18
  };
19
19
 
20
20
  type Message = {
@@ -24,7 +24,13 @@ type Message = {
24
24
  type SendOptions = {
25
25
  scheduledAt?: string;
26
26
  };
27
- type SmsStatus = 'SCHEDULED' | 'PENDING' | 'SENT' | 'DELIVERED' | 'FAILED';
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;
@@ -35,6 +41,7 @@ type TaskResponse = {
35
41
  _id: string;
36
42
  projectId: string;
37
43
  status: TaskStatus;
44
+ statusPage: TaskStatus;
38
45
  createdAt: string;
39
46
  scheduledAt?: string;
40
47
  };
@@ -75,4 +82,4 @@ declare class Ariari {
75
82
  static getTask: (taskId: string) => Promise<Task>;
76
83
  }
77
84
 
78
- 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://back.ariari.mg"}${endpoint}`;
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 {
@@ -89,12 +100,13 @@ var _Ariari = class _Ariari {
89
100
  const hasOptions = args[0] && "scheduledAt" in args[0];
90
101
  const options = hasOptions ? args[0] : {};
91
102
  const data = hasOptions ? args.slice(1) : args;
92
- const messages = data.map((item) => ({
93
- phones: (Array.isArray(item.phone) ? item.phone : [item.phone]).map(normalizePhoneNumber),
94
- message: item.message
95
- }));
96
- const body = { messages };
97
- if (options.scheduledAt) body.scheduledAt = options.scheduledAt;
103
+ const body = {
104
+ messages: data.map((item) => ({
105
+ phones: (Array.isArray(item.phone) ? item.phone : [item.phone]).map(normalizePhoneNumber),
106
+ message: item.message
107
+ })),
108
+ ...options.scheduledAt && { scheduledAt: options.scheduledAt }
109
+ };
98
110
  const response = await this._requester.post("/api/sms/bulk", { body });
99
111
  return new Task(response._id, this._requester);
100
112
  };
@@ -114,3 +126,7 @@ _Ariari.send = async (...args) => await _Ariari.get("main")?.send(...args);
114
126
  _Ariari.getTask = async (taskId) => _Ariari.get("main")?.getTask(taskId);
115
127
  var Ariari = _Ariari;
116
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://back.ariari.mg"}${endpoint}`;
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 {
@@ -63,12 +73,13 @@ var _Ariari = class _Ariari {
63
73
  const hasOptions = args[0] && "scheduledAt" in args[0];
64
74
  const options = hasOptions ? args[0] : {};
65
75
  const data = hasOptions ? args.slice(1) : args;
66
- const messages = data.map((item) => ({
67
- phones: (Array.isArray(item.phone) ? item.phone : [item.phone]).map(normalizePhoneNumber),
68
- message: item.message
69
- }));
70
- const body = { messages };
71
- if (options.scheduledAt) body.scheduledAt = options.scheduledAt;
76
+ const body = {
77
+ messages: data.map((item) => ({
78
+ phones: (Array.isArray(item.phone) ? item.phone : [item.phone]).map(normalizePhoneNumber),
79
+ message: item.message
80
+ })),
81
+ ...options.scheduledAt && { scheduledAt: options.scheduledAt }
82
+ };
72
83
  const response = await this._requester.post("/api/sms/bulk", { body });
73
84
  return new Task(response._id, this._requester);
74
85
  };
@@ -89,5 +100,6 @@ _Ariari.getTask = async (taskId) => _Ariari.get("main")?.getTask(taskId);
89
100
  var Ariari = _Ariari;
90
101
  var src_default = Ariari;
91
102
  export {
103
+ SmsStatus,
92
104
  src_default as default
93
105
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ariary/notification",
3
- "version": "3.0.3",
3
+ "version": "3.0.5",
4
4
  "description": "SMS et Notification Task SDK pour l'API Ariary",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",