@mhbdev/sms 0.0.0-stage → 0.2.0
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/CHANGELOG.md +17 -0
- package/LICENSE +21 -0
- package/README.md +146 -2
- package/dist/contracts/http.d.ts +10 -0
- package/dist/contracts/http.d.ts.map +1 -0
- package/dist/contracts/http.js +2 -0
- package/dist/contracts/http.js.map +1 -0
- package/dist/contracts/kavenegar.d.ts +53 -0
- package/dist/contracts/kavenegar.d.ts.map +1 -0
- package/dist/contracts/kavenegar.js +2 -0
- package/dist/contracts/kavenegar.js.map +1 -0
- package/dist/contracts/sms-ir.d.ts +55 -0
- package/dist/contracts/sms-ir.d.ts.map +1 -0
- package/dist/contracts/sms-ir.js +2 -0
- package/dist/contracts/sms-ir.js.map +1 -0
- package/dist/contracts/sms.d.ts +127 -0
- package/dist/contracts/sms.d.ts.map +1 -0
- package/dist/contracts/sms.js +2 -0
- package/dist/contracts/sms.js.map +1 -0
- package/dist/errors/kavenegar-error.d.ts +11 -0
- package/dist/errors/kavenegar-error.d.ts.map +1 -0
- package/dist/errors/kavenegar-error.js +11 -0
- package/dist/errors/kavenegar-error.js.map +1 -0
- package/dist/errors/sms-error.d.ts +24 -0
- package/dist/errors/sms-error.d.ts.map +1 -0
- package/dist/errors/sms-error.js +30 -0
- package/dist/errors/sms-error.js.map +1 -0
- package/dist/errors/sms-ir-error.d.ts +11 -0
- package/dist/errors/sms-ir-error.d.ts.map +1 -0
- package/dist/errors/sms-ir-error.js +11 -0
- package/dist/errors/sms-ir-error.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/kavenegar.d.ts +5 -0
- package/dist/kavenegar.d.ts.map +1 -0
- package/dist/kavenegar.js +4 -0
- package/dist/kavenegar.js.map +1 -0
- package/dist/providers/kavenegar/index.d.ts +5 -0
- package/dist/providers/kavenegar/index.d.ts.map +1 -0
- package/dist/providers/kavenegar/index.js +4 -0
- package/dist/providers/kavenegar/index.js.map +1 -0
- package/dist/providers/kavenegar/kavenegar-api.d.ts +14 -0
- package/dist/providers/kavenegar/kavenegar-api.d.ts.map +1 -0
- package/dist/providers/kavenegar/kavenegar-api.js +225 -0
- package/dist/providers/kavenegar/kavenegar-api.js.map +1 -0
- package/dist/providers/kavenegar/kavenegar-sms-provider.d.ts +35 -0
- package/dist/providers/kavenegar/kavenegar-sms-provider.d.ts.map +1 -0
- package/dist/providers/kavenegar/kavenegar-sms-provider.js +200 -0
- package/dist/providers/kavenegar/kavenegar-sms-provider.js.map +1 -0
- package/dist/providers/sms-ir/index.d.ts +5 -0
- package/dist/providers/sms-ir/index.d.ts.map +1 -0
- package/dist/providers/sms-ir/index.js +4 -0
- package/dist/providers/sms-ir/index.js.map +1 -0
- package/dist/providers/sms-ir/sms-ir-api.d.ts +15 -0
- package/dist/providers/sms-ir/sms-ir-api.d.ts.map +1 -0
- package/dist/providers/sms-ir/sms-ir-api.js +193 -0
- package/dist/providers/sms-ir/sms-ir-api.js.map +1 -0
- package/dist/providers/sms-ir/sms-ir-provider.d.ts +29 -0
- package/dist/providers/sms-ir/sms-ir-provider.d.ts.map +1 -0
- package/dist/providers/sms-ir/sms-ir-provider.js +165 -0
- package/dist/providers/sms-ir/sms-ir-provider.js.map +1 -0
- package/dist/sms-ir.d.ts +5 -0
- package/dist/sms-ir.d.ts.map +1 -0
- package/dist/sms-ir.js +4 -0
- package/dist/sms-ir.js.map +1 -0
- package/dist/transport/http.d.ts +37 -0
- package/dist/transport/http.d.ts.map +1 -0
- package/dist/transport/http.js +143 -0
- package/dist/transport/http.js.map +1 -0
- package/dist/validation/schemas.d.ts +174 -0
- package/dist/validation/schemas.d.ts.map +1 -0
- package/dist/validation/schemas.js +191 -0
- package/dist/validation/schemas.js.map +1 -0
- package/docs/architecture.md +73 -0
- package/docs/capabilities.md +27 -0
- package/docs/migration.md +39 -0
- package/package.json +85 -5
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
## 0.2.0
|
|
6
|
+
|
|
7
|
+
### Minor Changes
|
|
8
|
+
|
|
9
|
+
- [`7b80018`](https://github.com/mhbdev/sms/commit/7b80018a8531fee005d76545a077184e81a6d243) Thanks [@mhbdev](https://github.com/mhbdev)! - Add provider-specific capability contracts, scheduled-pack cancellation, typed sender support for Kavenegar, and runtime rejection of unsupported cross-provider fields.
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`7b80018`](https://github.com/mhbdev/sms/commit/7b80018a8531fee005d76545a077184e81a6d243) Thanks [@mhbdev](https://github.com/mhbdev)! - Add strict Zod 4.6.5 validation for provider configuration, requests, and API responses.
|
|
14
|
+
|
|
15
|
+
## 0.1.0
|
|
16
|
+
|
|
17
|
+
- Initial standalone release with Kavenegar and SMS.ir adapters.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 mhbdev
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,147 @@
|
|
|
1
|
-
#
|
|
1
|
+
# `@mhbdev/sms`
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Provider-neutral SMS delivery clients for Node.js 20+ and Bun, with first-class
|
|
4
|
+
adapters for [Kavenegar](https://kavenegar.com/rest.html) and
|
|
5
|
+
[SMS.ir](https://sms.ir/rest-api/).
|
|
6
|
+
|
|
7
|
+
The package uses the platform `fetch` API and Zod for strict runtime validation of
|
|
8
|
+
configuration, requests, and provider responses. It supports injected transports for
|
|
9
|
+
deterministic tests and never retries paid messages unless you explicitly configure a
|
|
10
|
+
retry policy.
|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
```sh
|
|
15
|
+
npm install @mhbdev/sms
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Kavenegar
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
import { KavenegarSmsProvider } from "@mhbdev/sms/kavenegar";
|
|
22
|
+
|
|
23
|
+
const sms = new KavenegarSmsProvider({
|
|
24
|
+
apiKey: process.env.KAVENEGAR_API_KEY!,
|
|
25
|
+
sender: "90005738",
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
await sms.sendMessage({
|
|
29
|
+
recipient: "+989121234567",
|
|
30
|
+
message: "Your order is ready.",
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
await sms.sendTemplate({
|
|
34
|
+
recipient: "+989121234567",
|
|
35
|
+
template: "my-otp-pattern",
|
|
36
|
+
parameters: ["123456"],
|
|
37
|
+
});
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
For Kavenegar raw, bulk, and send-array requests, `sender` in the provider
|
|
41
|
+
options is the default sender number. A message-level `sender` overrides it:
|
|
42
|
+
|
|
43
|
+
```ts
|
|
44
|
+
await sms.sendMessage({
|
|
45
|
+
recipient: "+989121234567",
|
|
46
|
+
message: "Sent from a specific line.",
|
|
47
|
+
sender: "10004346",
|
|
48
|
+
});
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Kavenegar's pattern/`VerifyLookup` API does not accept a sender number in its
|
|
52
|
+
request; Kavenegar selects the sender associated with the pattern. The sender
|
|
53
|
+
returned by Kavenegar is preserved in the normalized result when provided.
|
|
54
|
+
|
|
55
|
+
## SMS.ir
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
import { SmsIrProvider } from "@mhbdev/sms/sms-ir";
|
|
59
|
+
|
|
60
|
+
const sms = new SmsIrProvider({
|
|
61
|
+
apiKey: process.env.SMS_IR_API_KEY!,
|
|
62
|
+
lineNumber: "300000000000",
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
await sms.sendMessage({
|
|
66
|
+
recipient: "09121234567",
|
|
67
|
+
message: "Your order is ready.",
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
await sms.sendTemplate({
|
|
71
|
+
recipient: "09121234567",
|
|
72
|
+
templateId: 123456,
|
|
73
|
+
parameters: [{ name: "CODE", value: "123456" }],
|
|
74
|
+
});
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
SMS.ir raw and bulk contracts intentionally do not expose `sender`, `localId`,
|
|
78
|
+
or `tag`; SMS.ir uses the configured `lineNumber` and rejects unsupported fields
|
|
79
|
+
at runtime instead of silently ignoring them.
|
|
80
|
+
|
|
81
|
+
## Capability surface
|
|
82
|
+
|
|
83
|
+
Both adapters expose raw sending, provider-specific template sending, and the
|
|
84
|
+
provider's delivery/reporting operations. Kavenegar additionally exposes
|
|
85
|
+
send-array, scheduled-message cancellation, status-by-local-id, inbox, and
|
|
86
|
+
inbox-count operations. SMS.ir additionally exposes like-to-like delivery,
|
|
87
|
+
scheduled-pack cancellation, message status, and pack reports.
|
|
88
|
+
|
|
89
|
+
The capability contracts are generic so provider-specific request and result
|
|
90
|
+
types remain precise. Use `SmsMessageScheduler` for message-ID cancellation and
|
|
91
|
+
`SmsPackScheduler` for providers that cancel a provider-managed scheduled pack.
|
|
92
|
+
|
|
93
|
+
Use provider-specific types when a capability is not shared by both services. The
|
|
94
|
+
root import keeps the existing `@dordoone/sms` contract names available for
|
|
95
|
+
migrations:
|
|
96
|
+
|
|
97
|
+
```ts
|
|
98
|
+
import type { SmsMessageSender, SmsTemplateSender } from "@mhbdev/sms";
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Timeouts, aborts, and retries
|
|
102
|
+
|
|
103
|
+
Every provider accepts `timeoutMs`, an injected `fetcher`, a custom `baseUrl`,
|
|
104
|
+
additional headers, and an optional retry policy. Retries are disabled by default
|
|
105
|
+
because retrying after an unknown provider response can duplicate a paid SMS.
|
|
106
|
+
|
|
107
|
+
```ts
|
|
108
|
+
const sms = new SmsIrProvider({
|
|
109
|
+
apiKey: process.env.SMS_IR_API_KEY!,
|
|
110
|
+
lineNumber: "300000000000",
|
|
111
|
+
retry: {
|
|
112
|
+
maxAttempts: 3,
|
|
113
|
+
initialDelayMs: 250,
|
|
114
|
+
maxDelayMs: 2_000,
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Provider failures are represented by `KavenegarError` or `SmsIrError`. Errors
|
|
120
|
+
retain their original `cause`, stable error codes, provider status, HTTP status,
|
|
121
|
+
and retry metadata without including API keys in messages.
|
|
122
|
+
|
|
123
|
+
## Development
|
|
124
|
+
|
|
125
|
+
```sh
|
|
126
|
+
npm install
|
|
127
|
+
npm run typecheck
|
|
128
|
+
npm test
|
|
129
|
+
npm run lint
|
|
130
|
+
npm run build
|
|
131
|
+
npm run pack:check
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Live provider tests are intentionally not part of the default suite. Use mocked
|
|
135
|
+
fetchers for normal tests and run live tests only from a protected environment with
|
|
136
|
+
dedicated provider credentials.
|
|
137
|
+
|
|
138
|
+
## Migration from `@dordoone/sms`
|
|
139
|
+
|
|
140
|
+
The existing raw/template contracts and Kavenegar exports are preserved. Replace
|
|
141
|
+
the package name, then move provider-specific imports to `@mhbdev/sms/kavenegar`
|
|
142
|
+
when you want the explicit subpath form. The provider-neutral interfaces can be
|
|
143
|
+
used unchanged.
|
|
144
|
+
|
|
145
|
+
## License
|
|
146
|
+
|
|
147
|
+
MIT © 2026 mhbdev
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { RetryPolicy } from "../transport/http.js";
|
|
2
|
+
export type SmsHttpFetcher = (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
|
|
3
|
+
export type SmsHttpOptions = Readonly<{
|
|
4
|
+
timeoutMs?: number;
|
|
5
|
+
fetcher?: SmsHttpFetcher;
|
|
6
|
+
baseUrl?: string;
|
|
7
|
+
defaultHeaders?: Readonly<Record<string, string>>;
|
|
8
|
+
retry?: RetryPolicy;
|
|
9
|
+
}>;
|
|
10
|
+
//# sourceMappingURL=http.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/contracts/http.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAExD,MAAM,MAAM,cAAc,GAAG,CAC5B,KAAK,EAAE,MAAM,GAAG,GAAG,GAAG,OAAO,EAC7B,IAAI,CAAC,EAAE,WAAW,KACd,OAAO,CAAC,QAAQ,CAAC,CAAC;AAEvB,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAC;IACrC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,cAAc,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAClD,KAAK,CAAC,EAAE,WAAW,CAAC;CACpB,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../../src/contracts/http.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { SmsHttpOptions } from "./http.js";
|
|
2
|
+
import type { SmsBatchMessage, SmsBulkMessage, SmsBulkSendResult, SmsCancellationResult, SmsDeliveryStatus, SmsDeliveryStatusQuery, SmsReceivedMessage, SmsSendResult, SmsTemplateMessage } from "./sms.js";
|
|
3
|
+
export type KavenegarSmsProviderOptions = Readonly<SmsHttpOptions & {
|
|
4
|
+
apiKey: string;
|
|
5
|
+
/** Default sender number for raw, bulk, and send-array requests. */
|
|
6
|
+
sender?: string;
|
|
7
|
+
}>;
|
|
8
|
+
export type KavenegarSendResult = SmsSendResult & Readonly<{
|
|
9
|
+
provider: "kavenegar";
|
|
10
|
+
recipient?: string;
|
|
11
|
+
sender?: string;
|
|
12
|
+
statusText?: string;
|
|
13
|
+
date?: number;
|
|
14
|
+
cost?: number;
|
|
15
|
+
message?: string;
|
|
16
|
+
}>;
|
|
17
|
+
export type KavenegarSendArrayMessage = Omit<SmsBatchMessage, "sendAt" | "localId" | "signal">;
|
|
18
|
+
export type KavenegarStatusResult = SmsDeliveryStatus & Readonly<{
|
|
19
|
+
localId?: string;
|
|
20
|
+
}>;
|
|
21
|
+
export type KavenegarBulkRequest = SmsBulkMessage;
|
|
22
|
+
export type KavenegarBulkResult = SmsBulkSendResult;
|
|
23
|
+
export type KavenegarCancellationResult = SmsCancellationResult;
|
|
24
|
+
export type KavenegarReceivedMessage = SmsReceivedMessage;
|
|
25
|
+
export type KavenegarStatusQuery = SmsDeliveryStatusQuery;
|
|
26
|
+
export type KavenegarReceiveQuery = Readonly<{
|
|
27
|
+
lineNumber: string;
|
|
28
|
+
isRead: boolean;
|
|
29
|
+
signal?: AbortSignal;
|
|
30
|
+
}>;
|
|
31
|
+
export type KavenegarCountQuery = Readonly<{
|
|
32
|
+
startDate: number;
|
|
33
|
+
endDate?: number;
|
|
34
|
+
lineNumber?: string;
|
|
35
|
+
isRead?: boolean;
|
|
36
|
+
signal?: AbortSignal;
|
|
37
|
+
}>;
|
|
38
|
+
export type KavenegarCountResult = Readonly<{
|
|
39
|
+
startDate: number;
|
|
40
|
+
endDate: number;
|
|
41
|
+
count: number;
|
|
42
|
+
}>;
|
|
43
|
+
export type KavenegarSearchQuery = Readonly<{
|
|
44
|
+
messageIds?: readonly (string | number)[];
|
|
45
|
+
startDate: number;
|
|
46
|
+
endDate?: number;
|
|
47
|
+
lineNumber?: string;
|
|
48
|
+
page?: number;
|
|
49
|
+
pageSize?: number;
|
|
50
|
+
signal?: AbortSignal;
|
|
51
|
+
}>;
|
|
52
|
+
export type KavenegarTemplateMessage = SmsTemplateMessage;
|
|
53
|
+
//# sourceMappingURL=kavenegar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kavenegar.d.ts","sourceRoot":"","sources":["../../src/contracts/kavenegar.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,KAAK,EACX,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,qBAAqB,EACrB,iBAAiB,EACjB,sBAAsB,EACtB,kBAAkB,EAClB,aAAa,EACb,kBAAkB,EAClB,MAAM,UAAU,CAAC;AAElB,MAAM,MAAM,2BAA2B,GAAG,QAAQ,CACjD,cAAc,GAAG;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,oEAAoE;IACpE,MAAM,CAAC,EAAE,MAAM,CAAC;CAChB,CACD,CAAC;AAEF,MAAM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AM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACd,CAAC,CAAC;AAEH,MAAM,MAAM,oBAAoB,GAAG,QAAQ,CAAC;IAC3C,UAAU,CAAC,EAAE,SAAS,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;IAC1C,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,WAAW,CAAC;CACrB,CAAC,CAAC;AAEH,MAAM,MAAM,wBAAwB,GAAG,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kavenegar.js","sourceRoot":"","sources":["../../src/contracts/kavenegar.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { SmsHttpOptions } from "./http.js";
|
|
2
|
+
import type { SmsBulkMessage, SmsBulkSendResult, SmsCancellationResult, SmsDeliveryStatusQuery, SmsMessage, SmsSendResult } from "./sms.js";
|
|
3
|
+
export type SmsIrProviderOptions = Readonly<SmsHttpOptions & {
|
|
4
|
+
apiKey: string;
|
|
5
|
+
lineNumber: string | number;
|
|
6
|
+
}>;
|
|
7
|
+
export type SmsIrParameter = Readonly<{
|
|
8
|
+
name: string;
|
|
9
|
+
value: string;
|
|
10
|
+
}>;
|
|
11
|
+
export type SmsIrTemplateMessage = Readonly<{
|
|
12
|
+
recipient: string;
|
|
13
|
+
templateId: number;
|
|
14
|
+
parameters: readonly SmsIrParameter[];
|
|
15
|
+
signal?: AbortSignal;
|
|
16
|
+
}>;
|
|
17
|
+
export type SmsIrMessage = Omit<SmsMessage, "sender" | "localId" | "tag">;
|
|
18
|
+
export type SmsIrSendResult = SmsSendResult & Readonly<{
|
|
19
|
+
provider: "sms.ir";
|
|
20
|
+
cost?: number;
|
|
21
|
+
batchId?: string;
|
|
22
|
+
messageIds?: readonly (string | null)[];
|
|
23
|
+
}>;
|
|
24
|
+
export type SmsIrBulkMessage = Omit<SmsBulkMessage, "sender">;
|
|
25
|
+
export type SmsIrBulkSendResult = SmsBulkSendResult;
|
|
26
|
+
export type SmsIrStatusQuery = SmsDeliveryStatusQuery;
|
|
27
|
+
export type SmsIrCancellationResult = SmsCancellationResult;
|
|
28
|
+
export type SmsIrLikeToLikeMessage = Readonly<{
|
|
29
|
+
recipients: readonly string[];
|
|
30
|
+
messages: readonly string[];
|
|
31
|
+
sendAt?: number;
|
|
32
|
+
signal?: AbortSignal;
|
|
33
|
+
}>;
|
|
34
|
+
export type SmsIrMessageStatus = Readonly<{
|
|
35
|
+
messageId: string;
|
|
36
|
+
recipient: string;
|
|
37
|
+
message?: string;
|
|
38
|
+
sentAt?: number;
|
|
39
|
+
lineNumber?: string;
|
|
40
|
+
cost?: number;
|
|
41
|
+
deliveryStatus?: string;
|
|
42
|
+
deliveredAt?: number;
|
|
43
|
+
}>;
|
|
44
|
+
export type SmsIrPackQuery = Readonly<{
|
|
45
|
+
pageNumber?: number;
|
|
46
|
+
pageSize?: number;
|
|
47
|
+
signal?: AbortSignal;
|
|
48
|
+
}>;
|
|
49
|
+
export type SmsIrPackSummary = Readonly<{
|
|
50
|
+
packId: string;
|
|
51
|
+
recipientCount: number;
|
|
52
|
+
createdAt: number;
|
|
53
|
+
}>;
|
|
54
|
+
export type SmsIrPackMessage = SmsIrMessageStatus;
|
|
55
|
+
//# sourceMappingURL=sms-ir.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sms-ir.d.ts","sourceRoot":"","sources":["../../src/contracts/sms-ir.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,KAAK,EACX,cAAc,EACd,iBAAiB,EACjB,qBAAqB,E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AC5B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,WAAW,CAAC;CACrB,CAAC,CAAC;AAEH,MAAM,MAAM,kBAAkB,GAAG,QAAQ,CAAC;IACzC,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC,CAAC;AAEH,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAC;IACrC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,WAAW,CAAC;CACrB,CAAC,CAAC;AAEH,MAAM,MAAM,gBAAgB,GAAG,QAAQ,CAAC;IACvC,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;CAClB,CAAC,CAAC;AAEH,MAAM,MAAM,gBAAgB,GAAG,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sms-ir.js","sourceRoot":"","sources":["../../src/contracts/sms-ir.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/** A provider-neutral raw SMS message. */
|
|
2
|
+
export type SmsMessage = Readonly<{
|
|
3
|
+
recipient: string;
|
|
4
|
+
message: string;
|
|
5
|
+
/** Provider sender number override, when the provider supports sender selection. */
|
|
6
|
+
sender?: string;
|
|
7
|
+
sendAt?: number;
|
|
8
|
+
localId?: string | number;
|
|
9
|
+
tag?: string;
|
|
10
|
+
signal?: AbortSignal;
|
|
11
|
+
}>;
|
|
12
|
+
/** A provider-neutral pattern/template message with ordered parameters. */
|
|
13
|
+
export type SmsTemplateMessage = Readonly<{
|
|
14
|
+
recipient: string;
|
|
15
|
+
template: string;
|
|
16
|
+
parameters: readonly string[];
|
|
17
|
+
signal?: AbortSignal;
|
|
18
|
+
}>;
|
|
19
|
+
/** One message per recipient, useful for provider batch APIs. */
|
|
20
|
+
export type SmsBatchMessage = Readonly<{
|
|
21
|
+
recipient: string;
|
|
22
|
+
message: string;
|
|
23
|
+
/** Provider sender number override, when the provider supports sender selection. */
|
|
24
|
+
sender?: string;
|
|
25
|
+
sendAt?: number;
|
|
26
|
+
localId?: string | number;
|
|
27
|
+
signal?: AbortSignal;
|
|
28
|
+
}>;
|
|
29
|
+
/** A raw message addressed to one or more recipients. */
|
|
30
|
+
export type SmsBulkMessage = Readonly<{
|
|
31
|
+
recipients: readonly string[];
|
|
32
|
+
message: string;
|
|
33
|
+
/** Sender number override for the whole bulk request, when supported. */
|
|
34
|
+
sender?: string;
|
|
35
|
+
sendAt?: number;
|
|
36
|
+
signal?: AbortSignal;
|
|
37
|
+
}>;
|
|
38
|
+
/** Result status shared by all providers. */
|
|
39
|
+
export type SmsSendStatus = "accepted" | "scheduled" | "dry-run";
|
|
40
|
+
export type SmsSendResult = Readonly<{
|
|
41
|
+
provider: string;
|
|
42
|
+
messageId: string | null;
|
|
43
|
+
status: SmsSendStatus;
|
|
44
|
+
providerStatus?: string;
|
|
45
|
+
providerMessage?: string;
|
|
46
|
+
cost?: number;
|
|
47
|
+
batchId?: string;
|
|
48
|
+
recipient?: string;
|
|
49
|
+
}>;
|
|
50
|
+
export type SmsBulkSendResult = Readonly<{
|
|
51
|
+
provider: string;
|
|
52
|
+
batchId?: string;
|
|
53
|
+
messages: readonly SmsSendResult[];
|
|
54
|
+
cost?: number;
|
|
55
|
+
}>;
|
|
56
|
+
export type SmsDeliveryStatus = Readonly<{
|
|
57
|
+
messageId: string;
|
|
58
|
+
providerStatus: string;
|
|
59
|
+
statusText?: string;
|
|
60
|
+
deliveredAt?: number;
|
|
61
|
+
recipient?: string;
|
|
62
|
+
}>;
|
|
63
|
+
export type SmsDeliveryStatusQuery = Readonly<{
|
|
64
|
+
messageIds: readonly (string | number)[];
|
|
65
|
+
signal?: AbortSignal;
|
|
66
|
+
}>;
|
|
67
|
+
export type SmsCancellationResult = Readonly<{
|
|
68
|
+
provider: string;
|
|
69
|
+
messageId?: string;
|
|
70
|
+
batchId?: string;
|
|
71
|
+
providerStatus?: string;
|
|
72
|
+
statusText?: string;
|
|
73
|
+
returnedCredit?: number;
|
|
74
|
+
}>;
|
|
75
|
+
export type SmsMessageCancellationRequest = Readonly<{
|
|
76
|
+
ids: readonly (string | number)[];
|
|
77
|
+
}>;
|
|
78
|
+
export type SmsReceivedMessage = Readonly<{
|
|
79
|
+
messageId: string;
|
|
80
|
+
message: string;
|
|
81
|
+
sender: string;
|
|
82
|
+
recipient: string;
|
|
83
|
+
date?: number;
|
|
84
|
+
}>;
|
|
85
|
+
export type SmsCollection<T> = Readonly<{
|
|
86
|
+
items: readonly T[];
|
|
87
|
+
}>;
|
|
88
|
+
export type SmsPage<T> = SmsCollection<T> & Readonly<{
|
|
89
|
+
pageNumber?: number;
|
|
90
|
+
pageSize?: number;
|
|
91
|
+
}>;
|
|
92
|
+
/** Capability for providers that send raw SMS messages. */
|
|
93
|
+
export interface SmsMessageSender<TMessage = SmsMessage, TResult extends SmsSendResult = SmsSendResult> {
|
|
94
|
+
readonly name: string;
|
|
95
|
+
sendMessage(message: TMessage): Promise<TResult>;
|
|
96
|
+
}
|
|
97
|
+
/** Capability for providers that send provider-managed template messages. */
|
|
98
|
+
export interface SmsTemplateSender<TMessage = SmsTemplateMessage, TResult extends SmsSendResult = SmsSendResult> {
|
|
99
|
+
readonly name: string;
|
|
100
|
+
sendTemplate(message: TMessage): Promise<TResult>;
|
|
101
|
+
}
|
|
102
|
+
/** Capability for providers that send one message to multiple recipients. */
|
|
103
|
+
export interface SmsBulkSender<TMessage = SmsBulkMessage, TResult extends SmsBulkSendResult = SmsBulkSendResult> {
|
|
104
|
+
sendBulk(message: TMessage): Promise<TResult>;
|
|
105
|
+
}
|
|
106
|
+
/** Capability for providers that expose delivery status. */
|
|
107
|
+
export interface SmsDeliveryStatusReader<TQuery = SmsDeliveryStatusQuery, TResult = readonly SmsDeliveryStatus[]> {
|
|
108
|
+
getDeliveryStatus(query: TQuery): Promise<TResult>;
|
|
109
|
+
}
|
|
110
|
+
/** Capability for providers that can cancel scheduled messages or batches. */
|
|
111
|
+
export interface SmsScheduler<TCancellation = SmsCancellationResult> {
|
|
112
|
+
cancelScheduled(input: SmsMessageCancellationRequest): Promise<readonly TCancellation[]>;
|
|
113
|
+
}
|
|
114
|
+
/** Capability for providers that cancel scheduled messages by message ID. */
|
|
115
|
+
export interface SmsMessageScheduler<TCancellation = SmsCancellationResult> extends SmsScheduler<TCancellation> {
|
|
116
|
+
}
|
|
117
|
+
/** Capability for providers that cancel a provider-managed scheduled pack. */
|
|
118
|
+
export interface SmsPackScheduler<TCancellation = SmsCancellationResult> {
|
|
119
|
+
cancelScheduledPack(packId: string, options?: Readonly<{
|
|
120
|
+
signal?: AbortSignal;
|
|
121
|
+
}>): Promise<TCancellation>;
|
|
122
|
+
}
|
|
123
|
+
/** Capability for providers that expose inbound SMS messages. */
|
|
124
|
+
export interface SmsInboxReader<TQuery = unknown> {
|
|
125
|
+
getReceivedMessages(query: TQuery): Promise<SmsPage<SmsReceivedMessage>>;
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=sms.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sms.d.ts","sourceRoot":"","sources":["../../src/contracts/sms.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,oFAAoF;IACpF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAA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,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACnD;AAED,8EAA8E;AAC9E,MAAM,WAAW,YAAY,CAAC,aAAa,GAAG,qBAAqB;IAClE,eAAe,CACd,KAAK,EAAE,6BAA6B,GAClC,OAAO,CAAC,SAAS,aAAa,EAAE,CAAC,CAAC;CACrC;AAED,6EAA6E;AAC7E,MAAM,WAAW,mBAAmB,CAAC,aAAa,GAAG,qBAAqB,CACzE,SAAQ,YAAY,CAAC,aAAa,CAAC;CAAG;AAEvC,8EAA8E;AAC9E,MAAM,WAAW,gBAAgB,CAAC,aAAa,GAAG,qBAAqB;IACtE,mBAAmB,CAClB,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,QAAQ,CAAC;QAAE,MAAM,CAAC,EAAE,WAAW,CAAA;KAAE,CAAC,GAC1C,OAAO,CAAC,aAAa,CAAC,CAAC;CAC1B;AAED,iEAAiE;AACjE,MAAM,WAAW,cAAc,CAAC,MAAM,GAAG,OAAO;IAC/C,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC;CACzE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sms.js","sourceRoot":"","sources":["../../src/contracts/sms.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { SmsProviderError } from "./sms-error.js";
|
|
2
|
+
export declare class KavenegarError extends SmsProviderError {
|
|
3
|
+
constructor(message: string, options?: Readonly<{
|
|
4
|
+
cause?: unknown;
|
|
5
|
+
httpStatus?: number;
|
|
6
|
+
providerStatus?: number | string;
|
|
7
|
+
retryable?: boolean;
|
|
8
|
+
retryAfterMs?: number;
|
|
9
|
+
}>);
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=kavenegar-error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kavenegar-error.d.ts","sourceRoot":"","sources":["../../src/errors/kavenegar-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,qBAAa,cAAe,SAAQ,gBAAgB;IACnD,YACC,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,QAAQ,CAAC;QACjB,KAAK,CAAC,EAAE,OAAO,CAAC;QAChB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;QACjC,SAAS,CAAC,EAAE,OAAO,CAAC;QACpB,YAAY,CAAC,EAAE,MAAM,CAAC;KACtB,CAAM,EAOP;CACD"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { SmsProviderError } from "./sms-error.js";
|
|
2
|
+
export class KavenegarError extends SmsProviderError {
|
|
3
|
+
constructor(message, options = {}) {
|
|
4
|
+
super(message, {
|
|
5
|
+
...options,
|
|
6
|
+
code: "KAVENEGAR_ERROR",
|
|
7
|
+
});
|
|
8
|
+
this.name = "KavenegarError";
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=kavenegar-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kavenegar-error.js","sourceRoot":"","sources":["../../src/errors/kavenegar-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,MAAM,OAAO,cAAe,SAAQ,gBAAgB;IACnD,YACC,OAAe,EACf,OAAO,GAMF,EAAE;QAEP,KAAK,CAAC,OAAO,EAAE;YACd,GAAG,OAAO;YACV,IAAI,EAAE,iBAAiB;SACvB,CAAC,CAAC;QACH,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;IAC9B,CAAC;CACD"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export type SmsErrorOptions = Readonly<{
|
|
2
|
+
cause?: unknown;
|
|
3
|
+
code?: string;
|
|
4
|
+
httpStatus?: number;
|
|
5
|
+
providerStatus?: number | string;
|
|
6
|
+
retryable?: boolean;
|
|
7
|
+
retryAfterMs?: number;
|
|
8
|
+
}>;
|
|
9
|
+
export declare class SmsProviderError extends Error {
|
|
10
|
+
readonly code: string;
|
|
11
|
+
readonly isOperational = true;
|
|
12
|
+
readonly httpStatus?: number;
|
|
13
|
+
readonly providerStatus?: number | string;
|
|
14
|
+
readonly retryable?: boolean;
|
|
15
|
+
readonly retryAfterMs?: number;
|
|
16
|
+
constructor(message: string, options?: SmsErrorOptions);
|
|
17
|
+
}
|
|
18
|
+
export declare class SmsValidationError extends SmsProviderError {
|
|
19
|
+
constructor(message: string, options?: Omit<SmsErrorOptions, "code">);
|
|
20
|
+
}
|
|
21
|
+
export declare class SmsTransportError extends SmsProviderError {
|
|
22
|
+
constructor(message: string, options?: Omit<SmsErrorOptions, "code">);
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=sms-error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sms-error.d.ts","sourceRoot":"","sources":["../../src/errors/sms-error.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG,QAAQ,CAAC;IACtC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACjC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC,CAAC;AAEH,qBAAa,gBAAiB,SAAQ,KAAK;IAC1C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,aAAa,QAAQ;IAC9B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC1C,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAE/B,YAAY,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB,EAQzD;CACD;AAED,qBAAa,kBAAmB,SAAQ,gBAAgB;IACvD,YAAY,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,IAAI,CAAC,eAAe,EAAE,MAAM,CAAM,EAGvE;CACD;AAED,qBAAa,iBAAkB,SAAQ,gBAAgB;IACtD,YAAY,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,IAAI,CAAC,eAAe,EAAE,MAAM,CAAM,EAGvE;CACD"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export class SmsProviderError extends Error {
|
|
2
|
+
code;
|
|
3
|
+
isOperational = true;
|
|
4
|
+
httpStatus;
|
|
5
|
+
providerStatus;
|
|
6
|
+
retryable;
|
|
7
|
+
retryAfterMs;
|
|
8
|
+
constructor(message, options = {}) {
|
|
9
|
+
super(message, { cause: options.cause });
|
|
10
|
+
this.name = "SmsProviderError";
|
|
11
|
+
this.code = options.code ?? "SMS_PROVIDER_ERROR";
|
|
12
|
+
this.httpStatus = options.httpStatus;
|
|
13
|
+
this.providerStatus = options.providerStatus;
|
|
14
|
+
this.retryable = options.retryable;
|
|
15
|
+
this.retryAfterMs = options.retryAfterMs;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export class SmsValidationError extends SmsProviderError {
|
|
19
|
+
constructor(message, options = {}) {
|
|
20
|
+
super(message, { ...options, code: "SMS_VALIDATION_ERROR", retryable: false });
|
|
21
|
+
this.name = "SmsValidationError";
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export class SmsTransportError extends SmsProviderError {
|
|
25
|
+
constructor(message, options = {}) {
|
|
26
|
+
super(message, { ...options, code: "SMS_TRANSPORT_ERROR" });
|
|
27
|
+
this.name = "SmsTransportError";
|
|
28
|
+
}
|
|
29
|
+
}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,CAAC,IAAI,GAAG,mBAAmB,CAAC;IACjC,CAAC;CACD"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { SmsProviderError } from "./sms-error.js";
|
|
2
|
+
export declare class SmsIrError extends SmsProviderError {
|
|
3
|
+
constructor(message: string, options?: Readonly<{
|
|
4
|
+
cause?: unknown;
|
|
5
|
+
httpStatus?: number;
|
|
6
|
+
providerStatus?: number | string;
|
|
7
|
+
retryable?: boolean;
|
|
8
|
+
retryAfterMs?: number;
|
|
9
|
+
}>);
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=sms-ir-error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sms-ir-error.d.ts","sourceRoot":"","sources":["../../src/errors/sms-ir-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,qBAAa,UAAW,SAAQ,gBAAgB;IAC/C,YACC,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,QAAQ,CAAC;QACjB,KAAK,CAAC,EAAE,OAAO,CAAC;QAChB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;QACjC,SAAS,CAAC,EAAE,OAAO,CAAC;QACpB,YAAY,CAAC,EAAE,MAAM,CAAC;KACtB,CAAM,EAOP;CACD"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { SmsProviderError } from "./sms-error.js";
|
|
2
|
+
export class SmsIrError extends SmsProviderError {
|
|
3
|
+
constructor(message, options = {}) {
|
|
4
|
+
super(message, {
|
|
5
|
+
...options,
|
|
6
|
+
code: "SMS_IR_ERROR",
|
|
7
|
+
});
|
|
8
|
+
this.name = "SmsIrError";
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=sms-ir-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sms-ir-error.js","sourceRoot":"","sources":["../../src/errors/sms-ir-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,MAAM,OAAO,UAAW,SAAQ,gBAAgB;IAC/C,YACC,OAAe,EACf,OAAO,GAMF,EAAE;QAEP,KAAK,CAAC,OAAO,EAAE;YACd,GAAG,OAAO;YACV,IAAI,EAAE,cAAc;SACpB,CAAC,CAAC;QACH,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC;IAC1B,CAAC;CACD"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type { SmsHttpFetcher, SmsHttpOptions } from "./contracts/http.js";
|
|
2
|
+
export type { KavenegarBulkRequest, KavenegarBulkResult, KavenegarCancellationResult, KavenegarCountQuery, KavenegarCountResult, KavenegarReceivedMessage, KavenegarReceiveQuery, KavenegarSendArrayMessage, KavenegarSendResult, KavenegarSmsProviderOptions, KavenegarStatusQuery, KavenegarStatusResult, KavenegarTemplateMessage, } from "./contracts/kavenegar.js";
|
|
3
|
+
export type { SmsBatchMessage, SmsBulkMessage, SmsBulkSender, SmsBulkSendResult, SmsCancellationResult, SmsCollection, SmsDeliveryStatus, SmsDeliveryStatusQuery, SmsDeliveryStatusReader, SmsInboxReader, SmsMessage, SmsMessageCancellationRequest, SmsMessageScheduler, SmsMessageSender, SmsPackScheduler, SmsPage, SmsReceivedMessage, SmsScheduler, SmsSendResult, SmsSendStatus, SmsTemplateMessage, SmsTemplateSender, } from "./contracts/sms.js";
|
|
4
|
+
export type { SmsIrBulkMessage, SmsIrBulkSendResult, SmsIrCancellationResult, SmsIrLikeToLikeMessage, SmsIrMessage, SmsIrMessageStatus, SmsIrPackMessage, SmsIrPackQuery, SmsIrPackSummary, SmsIrParameter, SmsIrProviderOptions, SmsIrSendResult, SmsIrStatusQuery, SmsIrTemplateMessage, } from "./contracts/sms-ir.js";
|
|
5
|
+
export { KavenegarError } from "./errors/kavenegar-error.js";
|
|
6
|
+
export { SmsProviderError, SmsTransportError, SmsValidationError, } from "./errors/sms-error.js";
|
|
7
|
+
export { SmsIrError } from "./errors/sms-ir-error.js";
|
|
8
|
+
export { parseKavenegarCancellationResponse, parseKavenegarCountResponse, parseKavenegarPayload, parseKavenegarReceivedResponse, parseKavenegarResponse, parseKavenegarSendArrayResponse, parseKavenegarSendEntries, parseKavenegarStatusResponse, } from "./providers/kavenegar/kavenegar-api.js";
|
|
9
|
+
export { KavenegarSmsProvider } from "./providers/kavenegar/kavenegar-sms-provider.js";
|
|
10
|
+
export { parseSmsIrBulkResult, parseSmsIrCancellationResult, parseSmsIrMessageStatus, parseSmsIrPackMessages, parseSmsIrPackSummaries, parseSmsIrPayload, parseSmsIrSendResult, } from "./providers/sms-ir/sms-ir-api.js";
|
|
11
|
+
export { SmsIrProvider, SmsIrProvider as SmsIrSmsProvider, } from "./providers/sms-ir/sms-ir-provider.js";
|
|
12
|
+
export type { RetryContext, RetryPolicy } from "./transport/http.js";
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1E,YAAY,EACX,oBAAoB,EACpB,mBAAmB,EACnB,2BAA2B,EAC3B,mBAAmB,EACnB,oBAAoB,EACpB,wBAAwB,EACxB,qBAAqB,EACrB,yBAAyB,EACzB,mBAAmB,EACnB,2BAA2B,EAC3B,oBAAoB,EACpB,qBAAqB,EACrB,wBAAwB,GACxB,MAAM,0BAA0B,CAAC;AAClC,YAAY,EACX,eAAe,EACf,cAAc,EACd,aAAa,EACb,iBAAiB,EACjB,qBAAqB,EACrB,aAAa,EACb,iBAAiB,EACjB,sBAAsB,EACtB,uBAAuB,EACvB,cAAc,EACd,UAAU,EACV,6BAA6B,EAC7B,mBAAmB,EACnB,gB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