@ariary/notification 1.0.7 → 1.0.9
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/dist/index.d.mts +13 -29
- package/dist/index.d.ts +13 -29
- package/dist/index.js +41 -26
- package/dist/index.mjs +35 -26
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
interface ApiConfig {
|
|
2
|
-
projectId: string;
|
|
3
|
-
secretId: string;
|
|
4
|
-
baseUrl?: string;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
1
|
type Message = {
|
|
8
2
|
phone: string[] | string;
|
|
9
3
|
message: string;
|
|
@@ -17,30 +11,20 @@ type GetTaskParam = {
|
|
|
17
11
|
declare class Task {
|
|
18
12
|
id: string;
|
|
19
13
|
constructor(id: string);
|
|
20
|
-
status
|
|
21
|
-
detailedStatus
|
|
14
|
+
status(): Promise<unknown>;
|
|
15
|
+
detailedStatus(): Promise<unknown>;
|
|
22
16
|
}
|
|
23
|
-
declare class
|
|
24
|
-
private static instance;
|
|
25
|
-
private constructor();
|
|
26
|
-
static getInstance(): AriariBridge;
|
|
27
|
-
config(cfg: ApiConfig): void;
|
|
17
|
+
declare class Notification {
|
|
28
18
|
send(...data: Message[]): Promise<Task>;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
count: number;
|
|
39
|
-
order: 1 | -1;
|
|
40
|
-
} | undefined;
|
|
41
|
-
}>;
|
|
42
|
-
Task: typeof 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>;
|
|
43
28
|
}
|
|
44
|
-
declare const Ariari: AriariBridge;
|
|
45
29
|
|
|
46
|
-
export { Ariari
|
|
30
|
+
export { Ariari, type GetTaskParam, type Message, Notification, Task };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
interface ApiConfig {
|
|
2
|
-
projectId: string;
|
|
3
|
-
secretId: string;
|
|
4
|
-
baseUrl?: string;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
1
|
type Message = {
|
|
8
2
|
phone: string[] | string;
|
|
9
3
|
message: string;
|
|
@@ -17,30 +11,20 @@ type GetTaskParam = {
|
|
|
17
11
|
declare class Task {
|
|
18
12
|
id: string;
|
|
19
13
|
constructor(id: string);
|
|
20
|
-
status
|
|
21
|
-
detailedStatus
|
|
14
|
+
status(): Promise<unknown>;
|
|
15
|
+
detailedStatus(): Promise<unknown>;
|
|
22
16
|
}
|
|
23
|
-
declare class
|
|
24
|
-
private static instance;
|
|
25
|
-
private constructor();
|
|
26
|
-
static getInstance(): AriariBridge;
|
|
27
|
-
config(cfg: ApiConfig): void;
|
|
17
|
+
declare class Notification {
|
|
28
18
|
send(...data: Message[]): Promise<Task>;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
count: number;
|
|
39
|
-
order: 1 | -1;
|
|
40
|
-
} | undefined;
|
|
41
|
-
}>;
|
|
42
|
-
Task: typeof 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>;
|
|
43
28
|
}
|
|
44
|
-
declare const Ariari: AriariBridge;
|
|
45
29
|
|
|
46
|
-
export { Ariari
|
|
30
|
+
export { Ariari, type GetTaskParam, type Message, Notification, Task };
|
package/dist/index.js
CHANGED
|
@@ -20,7 +20,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var src_exports = {};
|
|
22
22
|
__export(src_exports, {
|
|
23
|
-
|
|
23
|
+
Ariari: () => Ariari,
|
|
24
|
+
Notification: () => Notification,
|
|
25
|
+
Task: () => Task
|
|
24
26
|
});
|
|
25
27
|
module.exports = __toCommonJS(src_exports);
|
|
26
28
|
|
|
@@ -80,39 +82,52 @@ async function httpPost(endpoint, body, requiresSecret = true) {
|
|
|
80
82
|
// src/index.ts
|
|
81
83
|
var Task = class {
|
|
82
84
|
constructor(id) {
|
|
83
|
-
this.status = () => httpGet(`/api/notif-task/${this.id}`);
|
|
84
|
-
this.detailedStatus = () => httpGet(`/api/notif-task/${this.id}/detailed`);
|
|
85
85
|
this.id = id;
|
|
86
86
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
constructor() {
|
|
90
|
-
this.tasks = async ({ from = 0, count = 20, order = -1 }) => {
|
|
91
|
-
return {
|
|
92
|
-
tasks: [],
|
|
93
|
-
next: { from: from + count + 1, count, order },
|
|
94
|
-
prev: from > 0 ? { from: from - count - 1, count, order } : void 0
|
|
95
|
-
};
|
|
96
|
-
};
|
|
97
|
-
this.Task = Task;
|
|
98
|
-
}
|
|
99
|
-
static getInstance() {
|
|
100
|
-
if (!_AriariBridge.instance) {
|
|
101
|
-
_AriariBridge.instance = new _AriariBridge();
|
|
102
|
-
}
|
|
103
|
-
return _AriariBridge.instance;
|
|
87
|
+
async status() {
|
|
88
|
+
return httpGet(`/api/sms/${this.id}/status`);
|
|
104
89
|
}
|
|
105
|
-
|
|
106
|
-
|
|
90
|
+
async detailedStatus() {
|
|
91
|
+
return httpGet(`/api/sms/${this.id}/detailed-status`);
|
|
107
92
|
}
|
|
93
|
+
};
|
|
94
|
+
var Notification = class {
|
|
108
95
|
async send(...data) {
|
|
109
96
|
const messages = data.map((item) => ({
|
|
110
97
|
phones: Array.isArray(item.phone) ? item.phone : [item.phone],
|
|
111
98
|
message: item.message
|
|
112
99
|
}));
|
|
113
|
-
const
|
|
114
|
-
|
|
100
|
+
const response = await httpPost("/api/sms/bulk", { messages });
|
|
101
|
+
if (!response.data || !Array.isArray(response.data) || response.data.length === 0) {
|
|
102
|
+
throw new Error("Invalid response: no SMS IDs returned");
|
|
103
|
+
}
|
|
104
|
+
return new Task(response.data[0]);
|
|
105
|
+
}
|
|
106
|
+
async sendMessage(data) {
|
|
107
|
+
return this.send(data);
|
|
108
|
+
}
|
|
109
|
+
async getMessages(param) {
|
|
110
|
+
return httpGet(`/api/sms?from=${param.from}&count=${param.count}&order=${param.order}`);
|
|
115
111
|
}
|
|
116
112
|
};
|
|
117
|
-
var Ariari =
|
|
118
|
-
|
|
113
|
+
var Ariari = class {
|
|
114
|
+
static config(config2) {
|
|
115
|
+
setConfig(config2);
|
|
116
|
+
}
|
|
117
|
+
static async sendMessage(data) {
|
|
118
|
+
return this.notification.sendMessage(data);
|
|
119
|
+
}
|
|
120
|
+
static async send(...data) {
|
|
121
|
+
return this.notification.send(...data);
|
|
122
|
+
}
|
|
123
|
+
static async getMessages(param) {
|
|
124
|
+
return this.notification.getMessages(param);
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
Ariari.notification = new Notification();
|
|
128
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
129
|
+
0 && (module.exports = {
|
|
130
|
+
Ariari,
|
|
131
|
+
Notification,
|
|
132
|
+
Task
|
|
133
|
+
});
|
package/dist/index.mjs
CHANGED
|
@@ -54,42 +54,51 @@ async function httpPost(endpoint, body, requiresSecret = true) {
|
|
|
54
54
|
// src/index.ts
|
|
55
55
|
var Task = class {
|
|
56
56
|
constructor(id) {
|
|
57
|
-
this.status = () => httpGet(`/api/notif-task/${this.id}`);
|
|
58
|
-
this.detailedStatus = () => httpGet(`/api/notif-task/${this.id}/detailed`);
|
|
59
57
|
this.id = id;
|
|
60
58
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
constructor() {
|
|
64
|
-
this.tasks = async ({ from = 0, count = 20, order = -1 }) => {
|
|
65
|
-
return {
|
|
66
|
-
tasks: [],
|
|
67
|
-
next: { from: from + count + 1, count, order },
|
|
68
|
-
prev: from > 0 ? { from: from - count - 1, count, order } : void 0
|
|
69
|
-
};
|
|
70
|
-
};
|
|
71
|
-
this.Task = Task;
|
|
72
|
-
}
|
|
73
|
-
static getInstance() {
|
|
74
|
-
if (!_AriariBridge.instance) {
|
|
75
|
-
_AriariBridge.instance = new _AriariBridge();
|
|
76
|
-
}
|
|
77
|
-
return _AriariBridge.instance;
|
|
59
|
+
async status() {
|
|
60
|
+
return httpGet(`/api/sms/${this.id}/status`);
|
|
78
61
|
}
|
|
79
|
-
|
|
80
|
-
|
|
62
|
+
async detailedStatus() {
|
|
63
|
+
return httpGet(`/api/sms/${this.id}/detailed-status`);
|
|
81
64
|
}
|
|
65
|
+
};
|
|
66
|
+
var Notification = class {
|
|
82
67
|
async send(...data) {
|
|
83
68
|
const messages = data.map((item) => ({
|
|
84
69
|
phones: Array.isArray(item.phone) ? item.phone : [item.phone],
|
|
85
70
|
message: item.message
|
|
86
71
|
}));
|
|
87
|
-
const
|
|
88
|
-
|
|
72
|
+
const response = await httpPost("/api/sms/bulk", { messages });
|
|
73
|
+
if (!response.data || !Array.isArray(response.data) || response.data.length === 0) {
|
|
74
|
+
throw new Error("Invalid response: no SMS IDs returned");
|
|
75
|
+
}
|
|
76
|
+
return new Task(response.data[0]);
|
|
77
|
+
}
|
|
78
|
+
async sendMessage(data) {
|
|
79
|
+
return this.send(data);
|
|
80
|
+
}
|
|
81
|
+
async getMessages(param) {
|
|
82
|
+
return httpGet(`/api/sms?from=${param.from}&count=${param.count}&order=${param.order}`);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
var Ariari = class {
|
|
86
|
+
static config(config2) {
|
|
87
|
+
setConfig(config2);
|
|
88
|
+
}
|
|
89
|
+
static async sendMessage(data) {
|
|
90
|
+
return this.notification.sendMessage(data);
|
|
91
|
+
}
|
|
92
|
+
static async send(...data) {
|
|
93
|
+
return this.notification.send(...data);
|
|
94
|
+
}
|
|
95
|
+
static async getMessages(param) {
|
|
96
|
+
return this.notification.getMessages(param);
|
|
89
97
|
}
|
|
90
98
|
};
|
|
91
|
-
|
|
92
|
-
var src_default = Ariari;
|
|
99
|
+
Ariari.notification = new Notification();
|
|
93
100
|
export {
|
|
94
|
-
|
|
101
|
+
Ariari,
|
|
102
|
+
Notification,
|
|
103
|
+
Task
|
|
95
104
|
};
|