auth-mn 0.1.0 → 0.1.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/dist/index.d.ts +9 -0
- package/dist/notification.d.ts +18 -0
- package/dist/notification.js +45 -2
- package/dist/socket.d.ts +83 -0
- package/dist/socket.js +134 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -46,6 +46,15 @@ declare const _default: {
|
|
|
46
46
|
data: null;
|
|
47
47
|
message: string;
|
|
48
48
|
}>;
|
|
49
|
+
SMS: (body: {
|
|
50
|
+
text: string;
|
|
51
|
+
to: string;
|
|
52
|
+
from: string;
|
|
53
|
+
}) => Promise<{
|
|
54
|
+
success: boolean;
|
|
55
|
+
data: null;
|
|
56
|
+
message: string;
|
|
57
|
+
}>;
|
|
49
58
|
};
|
|
50
59
|
};
|
|
51
60
|
export default _default;
|
package/dist/notification.d.ts
CHANGED
|
@@ -17,11 +17,29 @@ export declare const SinglePushNoti: (body: SinglePushNotiT) => Promise<{
|
|
|
17
17
|
data: null;
|
|
18
18
|
message: string;
|
|
19
19
|
}>;
|
|
20
|
+
export declare const SMS: (body: {
|
|
21
|
+
text: string;
|
|
22
|
+
to: string;
|
|
23
|
+
from: string;
|
|
24
|
+
}) => Promise<{
|
|
25
|
+
success: boolean;
|
|
26
|
+
data: null;
|
|
27
|
+
message: string;
|
|
28
|
+
}>;
|
|
20
29
|
declare const _default: {
|
|
21
30
|
SinglePushNoti: (body: SinglePushNotiT) => Promise<{
|
|
22
31
|
success: boolean;
|
|
23
32
|
data: null;
|
|
24
33
|
message: string;
|
|
25
34
|
}>;
|
|
35
|
+
SMS: (body: {
|
|
36
|
+
text: string;
|
|
37
|
+
to: string;
|
|
38
|
+
from: string;
|
|
39
|
+
}) => Promise<{
|
|
40
|
+
success: boolean;
|
|
41
|
+
data: null;
|
|
42
|
+
message: string;
|
|
43
|
+
}>;
|
|
26
44
|
};
|
|
27
45
|
export default _default;
|
package/dist/notification.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SinglePushNoti = void 0;
|
|
3
|
+
exports.SMS = exports.SinglePushNoti = void 0;
|
|
4
4
|
const _1 = require(".");
|
|
5
5
|
const auth_1 = require("./auth");
|
|
6
6
|
const axios_master_1 = require("axios-master");
|
|
@@ -47,4 +47,47 @@ const SinglePushNoti = async (body) => {
|
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
49
|
exports.SinglePushNoti = SinglePushNoti;
|
|
50
|
-
|
|
50
|
+
const SMS = async (body) => {
|
|
51
|
+
var _a;
|
|
52
|
+
try {
|
|
53
|
+
const result = await (0, axios_master_1.axiosMasterMain)({
|
|
54
|
+
method: "POST",
|
|
55
|
+
maxBodyLength: Infinity,
|
|
56
|
+
url: `${_1.config.hosts.MAIN}/main/v1/notification/sms`,
|
|
57
|
+
headers: {
|
|
58
|
+
Accept: "application/json",
|
|
59
|
+
"Content-Type": "application/json",
|
|
60
|
+
Authorization: `Bearer ${_1.config.token}`,
|
|
61
|
+
},
|
|
62
|
+
data: body,
|
|
63
|
+
}, {
|
|
64
|
+
name: "notification sms",
|
|
65
|
+
timeout: 20000,
|
|
66
|
+
retryFunction: auth_1.getToken,
|
|
67
|
+
shouldRetry: true,
|
|
68
|
+
shouldRetryStatus: [401, 400],
|
|
69
|
+
logger(data) {
|
|
70
|
+
if (_1.config.logger) {
|
|
71
|
+
console.log(data.json);
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
return { success: true, data: result.data, message: result.message };
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
const axiosError = error;
|
|
79
|
+
if (axiosError.data) {
|
|
80
|
+
console.log(axiosError.data);
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
console.error("Request Failed:", axiosError);
|
|
84
|
+
}
|
|
85
|
+
return {
|
|
86
|
+
success: false,
|
|
87
|
+
data: null,
|
|
88
|
+
message: ((_a = axiosError.data) === null || _a === void 0 ? void 0 : _a.message) || "",
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
exports.SMS = SMS;
|
|
93
|
+
exports.default = { SinglePushNoti: exports.SinglePushNoti, SMS: exports.SMS };
|
package/dist/socket.d.ts
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
export declare const ShowToast: (body: {
|
|
2
|
+
user_id: number;
|
|
3
|
+
type: "info" | "warning";
|
|
4
|
+
text: string;
|
|
5
|
+
}) => Promise<{
|
|
6
|
+
success: boolean;
|
|
7
|
+
data: null;
|
|
8
|
+
message: string;
|
|
9
|
+
}>;
|
|
10
|
+
export declare const ShowStatus: (body: {
|
|
11
|
+
user_id: number;
|
|
12
|
+
id: string;
|
|
13
|
+
type?: "Loading" | "Success" | "Failure";
|
|
14
|
+
title?: string;
|
|
15
|
+
amount?: number | string;
|
|
16
|
+
desc?: string;
|
|
17
|
+
footer?: {
|
|
18
|
+
text: string;
|
|
19
|
+
buttons: {
|
|
20
|
+
text: string;
|
|
21
|
+
fun: "href" | "close" | "exit";
|
|
22
|
+
href?: string | null;
|
|
23
|
+
}[];
|
|
24
|
+
};
|
|
25
|
+
show?: boolean;
|
|
26
|
+
expired_date?: Date;
|
|
27
|
+
start_date?: Date;
|
|
28
|
+
}) => Promise<{
|
|
29
|
+
success: boolean;
|
|
30
|
+
data: null;
|
|
31
|
+
message: string;
|
|
32
|
+
}>;
|
|
33
|
+
export declare const ShowOrderStatus: (body: {
|
|
34
|
+
user_id: number;
|
|
35
|
+
order_id: string;
|
|
36
|
+
}) => Promise<{
|
|
37
|
+
success: boolean;
|
|
38
|
+
data: null;
|
|
39
|
+
message: string;
|
|
40
|
+
}>;
|
|
41
|
+
declare const _default: {
|
|
42
|
+
ShowToast: (body: {
|
|
43
|
+
user_id: number;
|
|
44
|
+
type: "info" | "warning";
|
|
45
|
+
text: string;
|
|
46
|
+
}) => Promise<{
|
|
47
|
+
success: boolean;
|
|
48
|
+
data: null;
|
|
49
|
+
message: string;
|
|
50
|
+
}>;
|
|
51
|
+
ShowStatus: (body: {
|
|
52
|
+
user_id: number;
|
|
53
|
+
id: string;
|
|
54
|
+
type?: "Loading" | "Success" | "Failure";
|
|
55
|
+
title?: string;
|
|
56
|
+
amount?: number | string;
|
|
57
|
+
desc?: string;
|
|
58
|
+
footer?: {
|
|
59
|
+
text: string;
|
|
60
|
+
buttons: {
|
|
61
|
+
text: string;
|
|
62
|
+
fun: "href" | "close" | "exit";
|
|
63
|
+
href?: string | null;
|
|
64
|
+
}[];
|
|
65
|
+
};
|
|
66
|
+
show?: boolean;
|
|
67
|
+
expired_date?: Date;
|
|
68
|
+
start_date?: Date;
|
|
69
|
+
}) => Promise<{
|
|
70
|
+
success: boolean;
|
|
71
|
+
data: null;
|
|
72
|
+
message: string;
|
|
73
|
+
}>;
|
|
74
|
+
ShowOrderStatus: (body: {
|
|
75
|
+
user_id: number;
|
|
76
|
+
order_id: string;
|
|
77
|
+
}) => Promise<{
|
|
78
|
+
success: boolean;
|
|
79
|
+
data: null;
|
|
80
|
+
message: string;
|
|
81
|
+
}>;
|
|
82
|
+
};
|
|
83
|
+
export default _default;
|
package/dist/socket.js
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ShowOrderStatus = exports.ShowStatus = exports.ShowToast = void 0;
|
|
4
|
+
const _1 = require(".");
|
|
5
|
+
const auth_1 = require("./auth");
|
|
6
|
+
const axios_master_1 = require("axios-master");
|
|
7
|
+
const ShowToast = async (body) => {
|
|
8
|
+
var _a;
|
|
9
|
+
try {
|
|
10
|
+
const result = await (0, axios_master_1.axiosMasterMain)({
|
|
11
|
+
method: "POST",
|
|
12
|
+
maxBodyLength: Infinity,
|
|
13
|
+
url: `${_1.config.hosts.MAIN}/main/v1/socket/notification/toast`,
|
|
14
|
+
headers: {
|
|
15
|
+
Accept: "application/json",
|
|
16
|
+
"Content-Type": "application/json",
|
|
17
|
+
Authorization: `Bearer ${_1.config.token}`,
|
|
18
|
+
},
|
|
19
|
+
data: body,
|
|
20
|
+
}, {
|
|
21
|
+
name: "socket toast",
|
|
22
|
+
timeout: 20000,
|
|
23
|
+
retryFunction: auth_1.getToken,
|
|
24
|
+
shouldRetry: true,
|
|
25
|
+
shouldRetryStatus: [401, 400],
|
|
26
|
+
logger(data) {
|
|
27
|
+
if (_1.config.logger) {
|
|
28
|
+
console.log(data.json);
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
return { success: true, data: result.data, message: result.message };
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
const axiosError = error;
|
|
36
|
+
if (axiosError.data) {
|
|
37
|
+
console.log(axiosError.data);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
console.error("Request Failed:", axiosError);
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
success: false,
|
|
44
|
+
data: null,
|
|
45
|
+
message: ((_a = axiosError.data) === null || _a === void 0 ? void 0 : _a.message) || "",
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
exports.ShowToast = ShowToast;
|
|
50
|
+
const ShowStatus = async (body) => {
|
|
51
|
+
var _a;
|
|
52
|
+
try {
|
|
53
|
+
const result = await (0, axios_master_1.axiosMasterMain)({
|
|
54
|
+
method: "POST",
|
|
55
|
+
url: `${_1.config.hosts.MAIN}/main/v1/socket/notification/status`,
|
|
56
|
+
headers: {
|
|
57
|
+
Accept: "application/json",
|
|
58
|
+
"Content-Type": "application/json",
|
|
59
|
+
Authorization: `Bearer ${_1.config.token}`,
|
|
60
|
+
},
|
|
61
|
+
data: body,
|
|
62
|
+
}, {
|
|
63
|
+
name: "socket status",
|
|
64
|
+
timeout: 20000,
|
|
65
|
+
retryFunction: auth_1.getToken,
|
|
66
|
+
shouldRetry: true,
|
|
67
|
+
shouldRetryStatus: [401, 400],
|
|
68
|
+
logger(data) {
|
|
69
|
+
if (_1.config.logger) {
|
|
70
|
+
console.log(data.json);
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
return { success: true, data: result.data, message: result.message };
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
const axiosError = error;
|
|
78
|
+
if (axiosError.data) {
|
|
79
|
+
console.log(axiosError.data);
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
console.error("Request Failed:", axiosError);
|
|
83
|
+
}
|
|
84
|
+
return {
|
|
85
|
+
success: false,
|
|
86
|
+
data: null,
|
|
87
|
+
message: ((_a = axiosError.data) === null || _a === void 0 ? void 0 : _a.message) || "",
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
exports.ShowStatus = ShowStatus;
|
|
92
|
+
const ShowOrderStatus = async (body) => {
|
|
93
|
+
var _a;
|
|
94
|
+
try {
|
|
95
|
+
const result = await (0, axios_master_1.axiosMasterMain)({
|
|
96
|
+
method: "POST",
|
|
97
|
+
url: `${_1.config.hosts.MAIN}/main/v1/socket/notification/order/status`,
|
|
98
|
+
headers: {
|
|
99
|
+
Accept: "application/json",
|
|
100
|
+
"Content-Type": "application/json",
|
|
101
|
+
Authorization: `Bearer ${_1.config.token}`,
|
|
102
|
+
},
|
|
103
|
+
data: body,
|
|
104
|
+
}, {
|
|
105
|
+
name: "socket order status",
|
|
106
|
+
timeout: 20000,
|
|
107
|
+
retryFunction: auth_1.getToken,
|
|
108
|
+
shouldRetry: true,
|
|
109
|
+
shouldRetryStatus: [401, 400],
|
|
110
|
+
logger(data) {
|
|
111
|
+
if (_1.config.logger) {
|
|
112
|
+
console.log(data.json);
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
});
|
|
116
|
+
return { success: true, data: result.data, message: result.message };
|
|
117
|
+
}
|
|
118
|
+
catch (error) {
|
|
119
|
+
const axiosError = error;
|
|
120
|
+
if (axiosError.data) {
|
|
121
|
+
console.log(axiosError.data);
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
console.error("Request Failed:", axiosError);
|
|
125
|
+
}
|
|
126
|
+
return {
|
|
127
|
+
success: false,
|
|
128
|
+
data: null,
|
|
129
|
+
message: ((_a = axiosError.data) === null || _a === void 0 ? void 0 : _a.message) || "",
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
exports.ShowOrderStatus = ShowOrderStatus;
|
|
134
|
+
exports.default = { ShowToast: exports.ShowToast, ShowStatus: exports.ShowStatus, ShowOrderStatus: exports.ShowOrderStatus };
|