bridgex 2.1.0 → 2.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/package.json +2 -1
- package/dist/client/SMSManager.d.ts +0 -21
- package/dist/client/SMSManager.js +0 -41
- package/dist/client/types.d.ts +0 -18
- package/dist/client/types.js +0 -12
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bridgex",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"description": "a library for mazz app or a bridge for messaging that allow and automate the use of our service",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"messaging",
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"author": "MouadhBNB7741",
|
|
11
11
|
"type": "module",
|
|
12
12
|
"main": "main.ts",
|
|
13
|
+
"types": "dist/index.d.ts",
|
|
13
14
|
"scripts": {
|
|
14
15
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
15
16
|
"build": "tsc"
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { type RetryOptions } from "../RetryHandler.js";
|
|
2
|
-
interface SMSClientOptions {
|
|
3
|
-
baseUrl: string;
|
|
4
|
-
apiKey: string;
|
|
5
|
-
projectKey: string;
|
|
6
|
-
retry?: RetryOptions;
|
|
7
|
-
}
|
|
8
|
-
export declare class SMSClient {
|
|
9
|
-
private options;
|
|
10
|
-
private http;
|
|
11
|
-
private retry;
|
|
12
|
-
private formatter;
|
|
13
|
-
constructor(options: SMSClientOptions);
|
|
14
|
-
private validateOptions;
|
|
15
|
-
send(params: {
|
|
16
|
-
to: string;
|
|
17
|
-
template: string;
|
|
18
|
-
variables?: Record<string, unknown>;
|
|
19
|
-
}): Promise<any>;
|
|
20
|
-
}
|
|
21
|
-
export {};
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import HttpClient from "../HttpClient.js";
|
|
2
|
-
import RetryHandler from "../RetryHandler.js";
|
|
3
|
-
import MessageFormatter from "../MessageFormatter.js";
|
|
4
|
-
import { ValidationError } from "../errors.js";
|
|
5
|
-
export class SMSClient {
|
|
6
|
-
constructor(options) {
|
|
7
|
-
this.options = options;
|
|
8
|
-
this.validateOptions(options);
|
|
9
|
-
this.http = new HttpClient({
|
|
10
|
-
baseUrl: options.baseUrl,
|
|
11
|
-
apiKey: options.apiKey,
|
|
12
|
-
projectKey: options.projectKey,
|
|
13
|
-
});
|
|
14
|
-
this.retry = new RetryHandler(options.retry);
|
|
15
|
-
this.formatter = new MessageFormatter();
|
|
16
|
-
}
|
|
17
|
-
validateOptions(options) {
|
|
18
|
-
const { baseUrl, apiKey, projectKey } = options;
|
|
19
|
-
if (!baseUrl) {
|
|
20
|
-
throw new ValidationError("baseUrl is required");
|
|
21
|
-
}
|
|
22
|
-
if (!apiKey) {
|
|
23
|
-
throw new ValidationError("apiKey is required");
|
|
24
|
-
}
|
|
25
|
-
if (!projectKey) {
|
|
26
|
-
throw new ValidationError("projectKey is required");
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
async send(params) {
|
|
30
|
-
const { to, template, variables = {} } = params;
|
|
31
|
-
if (!to) {
|
|
32
|
-
throw new ValidationError("Recipient phone number is required");
|
|
33
|
-
}
|
|
34
|
-
const message = this.formatter.format(template, variables);
|
|
35
|
-
const payload = {
|
|
36
|
-
to,
|
|
37
|
-
message,
|
|
38
|
-
};
|
|
39
|
-
return this.retry.execute(() => this.http.post("/sms/send", payload));
|
|
40
|
-
}
|
|
41
|
-
}
|
package/dist/client/types.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
type SMSClientConfigMode = "BASE" | "FAULT_TOLERANT";
|
|
2
|
-
type RetryOptions = {};
|
|
3
|
-
type CircuitBreakerOptions = {};
|
|
4
|
-
type BatchingOptions = {};
|
|
5
|
-
type QueueOptions = {};
|
|
6
|
-
export default class SMSClientConfig {
|
|
7
|
-
baseUrl: string;
|
|
8
|
-
apiKey: string;
|
|
9
|
-
mode: SMSClientConfigMode;
|
|
10
|
-
timeout: number;
|
|
11
|
-
retryOptions: RetryOptions;
|
|
12
|
-
circuitBreakerOptions: CircuitBreakerOptions;
|
|
13
|
-
batchingOptions: BatchingOptions;
|
|
14
|
-
queueOptions: QueueOptions;
|
|
15
|
-
constructor(baseUrl: string, apiKey: string, mode: SMSClientConfigMode, timeout: number, retryOptions: RetryOptions, circuitBreakerOptions: CircuitBreakerOptions, batchingOptions: BatchingOptions, queueOptions: QueueOptions);
|
|
16
|
-
}
|
|
17
|
-
export type Result = [string, Error | null];
|
|
18
|
-
export {};
|
package/dist/client/types.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export default class SMSClientConfig {
|
|
2
|
-
constructor(baseUrl, apiKey, mode, timeout, retryOptions, circuitBreakerOptions, batchingOptions, queueOptions) {
|
|
3
|
-
this.baseUrl = baseUrl;
|
|
4
|
-
this.apiKey = apiKey;
|
|
5
|
-
this.mode = mode;
|
|
6
|
-
this.timeout = timeout;
|
|
7
|
-
this.retryOptions = retryOptions;
|
|
8
|
-
this.circuitBreakerOptions = circuitBreakerOptions;
|
|
9
|
-
this.batchingOptions = batchingOptions;
|
|
10
|
-
this.queueOptions = queueOptions;
|
|
11
|
-
}
|
|
12
|
-
}
|