@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.
Files changed (79) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/LICENSE +21 -0
  3. package/README.md +146 -2
  4. package/dist/contracts/http.d.ts +10 -0
  5. package/dist/contracts/http.d.ts.map +1 -0
  6. package/dist/contracts/http.js +2 -0
  7. package/dist/contracts/http.js.map +1 -0
  8. package/dist/contracts/kavenegar.d.ts +53 -0
  9. package/dist/contracts/kavenegar.d.ts.map +1 -0
  10. package/dist/contracts/kavenegar.js +2 -0
  11. package/dist/contracts/kavenegar.js.map +1 -0
  12. package/dist/contracts/sms-ir.d.ts +55 -0
  13. package/dist/contracts/sms-ir.d.ts.map +1 -0
  14. package/dist/contracts/sms-ir.js +2 -0
  15. package/dist/contracts/sms-ir.js.map +1 -0
  16. package/dist/contracts/sms.d.ts +127 -0
  17. package/dist/contracts/sms.d.ts.map +1 -0
  18. package/dist/contracts/sms.js +2 -0
  19. package/dist/contracts/sms.js.map +1 -0
  20. package/dist/errors/kavenegar-error.d.ts +11 -0
  21. package/dist/errors/kavenegar-error.d.ts.map +1 -0
  22. package/dist/errors/kavenegar-error.js +11 -0
  23. package/dist/errors/kavenegar-error.js.map +1 -0
  24. package/dist/errors/sms-error.d.ts +24 -0
  25. package/dist/errors/sms-error.d.ts.map +1 -0
  26. package/dist/errors/sms-error.js +30 -0
  27. package/dist/errors/sms-error.js.map +1 -0
  28. package/dist/errors/sms-ir-error.d.ts +11 -0
  29. package/dist/errors/sms-ir-error.d.ts.map +1 -0
  30. package/dist/errors/sms-ir-error.js +11 -0
  31. package/dist/errors/sms-ir-error.js.map +1 -0
  32. package/dist/index.d.ts +13 -0
  33. package/dist/index.d.ts.map +1 -0
  34. package/dist/index.js +8 -0
  35. package/dist/index.js.map +1 -0
  36. package/dist/kavenegar.d.ts +5 -0
  37. package/dist/kavenegar.d.ts.map +1 -0
  38. package/dist/kavenegar.js +4 -0
  39. package/dist/kavenegar.js.map +1 -0
  40. package/dist/providers/kavenegar/index.d.ts +5 -0
  41. package/dist/providers/kavenegar/index.d.ts.map +1 -0
  42. package/dist/providers/kavenegar/index.js +4 -0
  43. package/dist/providers/kavenegar/index.js.map +1 -0
  44. package/dist/providers/kavenegar/kavenegar-api.d.ts +14 -0
  45. package/dist/providers/kavenegar/kavenegar-api.d.ts.map +1 -0
  46. package/dist/providers/kavenegar/kavenegar-api.js +225 -0
  47. package/dist/providers/kavenegar/kavenegar-api.js.map +1 -0
  48. package/dist/providers/kavenegar/kavenegar-sms-provider.d.ts +35 -0
  49. package/dist/providers/kavenegar/kavenegar-sms-provider.d.ts.map +1 -0
  50. package/dist/providers/kavenegar/kavenegar-sms-provider.js +200 -0
  51. package/dist/providers/kavenegar/kavenegar-sms-provider.js.map +1 -0
  52. package/dist/providers/sms-ir/index.d.ts +5 -0
  53. package/dist/providers/sms-ir/index.d.ts.map +1 -0
  54. package/dist/providers/sms-ir/index.js +4 -0
  55. package/dist/providers/sms-ir/index.js.map +1 -0
  56. package/dist/providers/sms-ir/sms-ir-api.d.ts +15 -0
  57. package/dist/providers/sms-ir/sms-ir-api.d.ts.map +1 -0
  58. package/dist/providers/sms-ir/sms-ir-api.js +193 -0
  59. package/dist/providers/sms-ir/sms-ir-api.js.map +1 -0
  60. package/dist/providers/sms-ir/sms-ir-provider.d.ts +29 -0
  61. package/dist/providers/sms-ir/sms-ir-provider.d.ts.map +1 -0
  62. package/dist/providers/sms-ir/sms-ir-provider.js +165 -0
  63. package/dist/providers/sms-ir/sms-ir-provider.js.map +1 -0
  64. package/dist/sms-ir.d.ts +5 -0
  65. package/dist/sms-ir.d.ts.map +1 -0
  66. package/dist/sms-ir.js +4 -0
  67. package/dist/sms-ir.js.map +1 -0
  68. package/dist/transport/http.d.ts +37 -0
  69. package/dist/transport/http.d.ts.map +1 -0
  70. package/dist/transport/http.js +143 -0
  71. package/dist/transport/http.js.map +1 -0
  72. package/dist/validation/schemas.d.ts +174 -0
  73. package/dist/validation/schemas.d.ts.map +1 -0
  74. package/dist/validation/schemas.js +191 -0
  75. package/dist/validation/schemas.js.map +1 -0
  76. package/docs/architecture.md +73 -0
  77. package/docs/capabilities.md +27 -0
  78. package/docs/migration.md +39 -0
  79. package/package.json +85 -5
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.js","sourceRoot":"","sources":["../../src/transport/http.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAqB/E,MAAM,sBAAsB,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AAExD,MAAM,OAAO,gBAAgB;IACX,OAAO,CAAiB;IACxB,SAAS,CAAS;IAClB,KAAK,CAAe;IACpB,cAAc,CAAmC;IAElE,YACC,OAKE;QAEF,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,OAAO,CAAC,SAAS,IAAI,CAAC,EAAE,CAAC;YACxE,MAAM,IAAI,kBAAkB,CAAC,wCAAwC,CAAC,CAAC;QACxE,CAAC;QACD,mBAAmB,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QACnC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QAC/B,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;QACnC,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC3B,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC,cAAc,IAAI,EAAE,CAAC;IACpD,CAAC;IAED,KAAK,CAAC,OAAO,CACZ,KAAmB,EACnB,IAAiB,EACjB,OAAO,GAAmB,EAAE;QAE5B,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,EAAE,WAAW,IAAI,CAAC,CAAC;QACjD,KAAK,IAAI,OAAO,GAAG,CAAC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AAED,MAAM,UAAU,sBAAsB,CAAC,KAAa,EAAE,IAAY;IACjE,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE;QAAE,MAAM,IAAI,kBAAkB,CAAC,GAAG,IAAI,cAAc,CAAC,CAAC;IACvE,OAAO,KAAK,CAAC;AACd,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,UAA6B;IAC/D,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC;QAC1B,MAAM,IAAI,kBAAkB,CAAC,oCAAoC,CAAC,CAAC;IACpE,KAAK,MAAM,SAAS,IAAI,UAAU;QAAE,sBAAsB,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;AACpF,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,KAAgC;IAC7D,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC1C,MAAM,OAAO,GAAG,KAAK,YAAY,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IACpF,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,OAAO,GAAG,CAAC,EAAE,CAAC;QACnD,MAAM,IAAI,kBAAkB,CAAC,8CAA8C,CAAC,CAAC;IAC9E,CAAC;IACD,OAAO,OAAO,CAAC;AAChB,CAAC"}
@@ -0,0 +1,174 @@
1
+ import { z } from "zod";
2
+ import type { SmsHttpFetcher } from "../contracts/http.js";
3
+ /** A string that cannot be blank, while preserving the caller's original value. */
4
+ export declare const nonBlankStringSchema: z.ZodString;
5
+ export declare const finiteNumberSchema: z.ZodNumber;
6
+ export declare const nonNegativeIntegerSchema: z.ZodNumber;
7
+ export declare const positiveIntegerSchema: z.ZodNumber;
8
+ export declare const localIdSchema: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
9
+ export declare const sendAtSchema: z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodDate]>, z.ZodTransform<number, number | Date>>;
10
+ export declare const abortSignalSchema: z.ZodCustom<AbortSignal, AbortSignal>;
11
+ export declare const kavenegarOptionsSchema: z.ZodObject<{
12
+ timeoutMs: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
13
+ fetcher: z.ZodOptional<z.ZodOptional<z.ZodCustom<SmsHttpFetcher, SmsHttpFetcher>>>;
14
+ baseUrl: z.ZodOptional<z.ZodOptional<z.ZodString>>;
15
+ defaultHeaders: z.ZodOptional<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>>;
16
+ retry: z.ZodOptional<z.ZodOptional<z.ZodPipe<z.ZodObject<{
17
+ maxAttempts: z.ZodNumber;
18
+ initialDelayMs: z.ZodOptional<z.ZodNumber>;
19
+ maxDelayMs: z.ZodOptional<z.ZodNumber>;
20
+ backoffMultiplier: z.ZodOptional<z.ZodNumber>;
21
+ retryOn: z.ZodOptional<z.ZodCustom<(...args: never[]) => unknown, (...args: never[]) => unknown>>;
22
+ sleep: z.ZodOptional<z.ZodCustom<(...args: never[]) => unknown, (...args: never[]) => unknown>>;
23
+ }, z.core.$loose>, z.ZodTransform<Readonly<{
24
+ maxAttempts: number;
25
+ initialDelayMs?: number;
26
+ maxDelayMs?: number;
27
+ backoffMultiplier?: number;
28
+ retryOn?: (context: import("../transport/http.js").RetryContext) => boolean;
29
+ sleep?: (delayMs: number, signal?: AbortSignal) => Promise<void>;
30
+ }>, {
31
+ [x: string]: unknown;
32
+ maxAttempts: number;
33
+ initialDelayMs?: number | undefined;
34
+ maxDelayMs?: number | undefined;
35
+ backoffMultiplier?: number | undefined;
36
+ retryOn?: ((...args: never[]) => unknown) | undefined;
37
+ sleep?: ((...args: never[]) => unknown) | undefined;
38
+ }>>>>;
39
+ apiKey: z.ZodString;
40
+ sender: z.ZodOptional<z.ZodString>;
41
+ }, z.core.$loose>;
42
+ export declare const smsIrOptionsSchema: z.ZodObject<{
43
+ timeoutMs: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
44
+ fetcher: z.ZodOptional<z.ZodOptional<z.ZodCustom<SmsHttpFetcher, SmsHttpFetcher>>>;
45
+ baseUrl: z.ZodOptional<z.ZodOptional<z.ZodString>>;
46
+ defaultHeaders: z.ZodOptional<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>>;
47
+ retry: z.ZodOptional<z.ZodOptional<z.ZodPipe<z.ZodObject<{
48
+ maxAttempts: z.ZodNumber;
49
+ initialDelayMs: z.ZodOptional<z.ZodNumber>;
50
+ maxDelayMs: z.ZodOptional<z.ZodNumber>;
51
+ backoffMultiplier: z.ZodOptional<z.ZodNumber>;
52
+ retryOn: z.ZodOptional<z.ZodCustom<(...args: never[]) => unknown, (...args: never[]) => unknown>>;
53
+ sleep: z.ZodOptional<z.ZodCustom<(...args: never[]) => unknown, (...args: never[]) => unknown>>;
54
+ }, z.core.$loose>, z.ZodTransform<Readonly<{
55
+ maxAttempts: number;
56
+ initialDelayMs?: number;
57
+ maxDelayMs?: number;
58
+ backoffMultiplier?: number;
59
+ retryOn?: (context: import("../transport/http.js").RetryContext) => boolean;
60
+ sleep?: (delayMs: number, signal?: AbortSignal) => Promise<void>;
61
+ }>, {
62
+ [x: string]: unknown;
63
+ maxAttempts: number;
64
+ initialDelayMs?: number | undefined;
65
+ maxDelayMs?: number | undefined;
66
+ backoffMultiplier?: number | undefined;
67
+ retryOn?: ((...args: never[]) => unknown) | undefined;
68
+ sleep?: ((...args: never[]) => unknown) | undefined;
69
+ }>>>>;
70
+ apiKey: z.ZodString;
71
+ lineNumber: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
72
+ }, z.core.$loose>;
73
+ export declare const smsMessageSchema: z.ZodObject<{
74
+ recipient: z.ZodString;
75
+ message: z.ZodString;
76
+ sender: z.ZodOptional<z.ZodString>;
77
+ sendAt: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodDate]>, z.ZodTransform<number, number | Date>>>;
78
+ localId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
79
+ tag: z.ZodOptional<z.ZodString>;
80
+ signal: z.ZodOptional<z.ZodCustom<AbortSignal, AbortSignal>>;
81
+ }, z.core.$loose>;
82
+ export declare const smsBulkMessageSchema: z.ZodObject<{
83
+ recipients: z.ZodArray<z.ZodString>;
84
+ message: z.ZodString;
85
+ sender: z.ZodOptional<z.ZodString>;
86
+ sendAt: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodDate]>, z.ZodTransform<number, number | Date>>>;
87
+ signal: z.ZodOptional<z.ZodCustom<AbortSignal, AbortSignal>>;
88
+ }, z.core.$loose>;
89
+ export declare const smsIrMessageSchema: z.ZodObject<{
90
+ recipient: z.ZodString;
91
+ message: z.ZodString;
92
+ sendAt: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodDate]>, z.ZodTransform<number, number | Date>>>;
93
+ signal: z.ZodOptional<z.ZodCustom<AbortSignal, AbortSignal>>;
94
+ }, z.core.$strict>;
95
+ export declare const smsIrBulkMessageSchema: z.ZodObject<{
96
+ recipients: z.ZodArray<z.ZodString>;
97
+ message: z.ZodString;
98
+ sendAt: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodDate]>, z.ZodTransform<number, number | Date>>>;
99
+ signal: z.ZodOptional<z.ZodCustom<AbortSignal, AbortSignal>>;
100
+ }, z.core.$strict>;
101
+ export declare const smsBatchMessageSchema: z.ZodObject<{
102
+ recipient: z.ZodString;
103
+ message: z.ZodString;
104
+ sender: z.ZodOptional<z.ZodString>;
105
+ sendAt: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodDate]>, z.ZodTransform<number, number | Date>>>;
106
+ localId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
107
+ signal: z.ZodOptional<z.ZodCustom<AbortSignal, AbortSignal>>;
108
+ }, z.core.$loose>;
109
+ export declare const kavenegarSendArrayMessageSchema: z.ZodObject<{
110
+ recipient: z.ZodString;
111
+ message: z.ZodString;
112
+ sender: z.ZodOptional<z.ZodString>;
113
+ }, z.core.$strict>;
114
+ export declare const signalOptionsSchema: z.ZodObject<{
115
+ signal: z.ZodOptional<z.ZodCustom<AbortSignal, AbortSignal>>;
116
+ }, z.core.$loose>;
117
+ export declare const idsInputSchema: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
118
+ export declare const cancellationInputSchema: z.ZodObject<{
119
+ ids: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
120
+ }, z.core.$loose>;
121
+ export declare const deliveryStatusQuerySchema: z.ZodObject<{
122
+ messageIds: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
123
+ signal: z.ZodOptional<z.ZodCustom<AbortSignal, AbortSignal>>;
124
+ }, z.core.$loose>;
125
+ export declare const kavenegarTemplateSchema: z.ZodObject<{
126
+ recipient: z.ZodString;
127
+ template: z.ZodString;
128
+ parameters: z.ZodArray<z.ZodString>;
129
+ signal: z.ZodOptional<z.ZodCustom<AbortSignal, AbortSignal>>;
130
+ }, z.core.$loose>;
131
+ export declare const kavenegarReceiveQuerySchema: z.ZodObject<{
132
+ lineNumber: z.ZodString;
133
+ isRead: z.ZodBoolean;
134
+ signal: z.ZodOptional<z.ZodCustom<AbortSignal, AbortSignal>>;
135
+ }, z.core.$loose>;
136
+ export declare const kavenegarCountQuerySchema: z.ZodObject<{
137
+ startDate: z.ZodNumber;
138
+ endDate: z.ZodOptional<z.ZodNumber>;
139
+ lineNumber: z.ZodOptional<z.ZodString>;
140
+ isRead: z.ZodOptional<z.ZodBoolean>;
141
+ signal: z.ZodOptional<z.ZodCustom<AbortSignal, AbortSignal>>;
142
+ }, z.core.$loose>;
143
+ export declare const kavenegarSearchQuerySchema: z.ZodObject<{
144
+ messageIds: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
145
+ startDate: z.ZodNumber;
146
+ endDate: z.ZodOptional<z.ZodNumber>;
147
+ lineNumber: z.ZodOptional<z.ZodString>;
148
+ page: z.ZodOptional<z.ZodNumber>;
149
+ pageSize: z.ZodOptional<z.ZodNumber>;
150
+ signal: z.ZodOptional<z.ZodCustom<AbortSignal, AbortSignal>>;
151
+ }, z.core.$loose>;
152
+ export declare const smsIrTemplateSchema: z.ZodObject<{
153
+ recipient: z.ZodString;
154
+ templateId: z.ZodNumber;
155
+ parameters: z.ZodArray<z.ZodObject<{
156
+ name: z.ZodString;
157
+ value: z.ZodString;
158
+ }, z.core.$strip>>;
159
+ signal: z.ZodOptional<z.ZodCustom<AbortSignal, AbortSignal>>;
160
+ }, z.core.$loose>;
161
+ export declare const smsIrLikeToLikeSchema: z.ZodObject<{
162
+ recipients: z.ZodArray<z.ZodString>;
163
+ messages: z.ZodArray<z.ZodString>;
164
+ sendAt: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodDate]>, z.ZodTransform<number, number | Date>>>;
165
+ signal: z.ZodOptional<z.ZodCustom<AbortSignal, AbortSignal>>;
166
+ }, z.core.$loose>;
167
+ export declare const packQuerySchema: z.ZodObject<{
168
+ pageNumber: z.ZodOptional<z.ZodNumber>;
169
+ pageSize: z.ZodOptional<z.ZodNumber>;
170
+ signal: z.ZodOptional<z.ZodCustom<AbortSignal, AbortSignal>>;
171
+ }, z.core.$loose>;
172
+ export declare function formatZodIssues(error: z.ZodError): string;
173
+ export declare function parseInput<TSchema extends z.ZodType>(schema: TSchema, value: unknown, createError: (message: string, cause: z.ZodError) => Error): z.output<TSchema>;
174
+ //# sourceMappingURL=schemas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../src/validation/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,cAA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AAO,MAAM,qBAAqB;;;;;iBAWzB,CAAC;AAEV,eAAO,MAAM,eAAe;;;;iBAMnB,CAAC;AAEV,wBAAgB,eAAe,CAAC,KAAK,EAAE,CAAC,CAAC,QAAQ,GAAG,MAAM,CAOzD;AAED,wBAAgB,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC,OAAO,EACnD,MAAM,EAAE,OAAO,EACf,KAAK,EAAE,OAAO,EACd,WAAW,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,QAAQ,KAAK,KAAK,GACxD,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAMnB"}
@@ -0,0 +1,191 @@
1
+ import { z } from "zod";
2
+ /** A string that cannot be blank, while preserving the caller's original value. */
3
+ export const nonBlankStringSchema = z.string().refine((value) => value.trim().length > 0);
4
+ export const finiteNumberSchema = z.number().finite();
5
+ export const nonNegativeIntegerSchema = z.number().int().nonnegative();
6
+ export const positiveIntegerSchema = z
7
+ .number()
8
+ .int()
9
+ .positive({ message: "must be a positive integer" });
10
+ export const localIdSchema = z.union([nonBlankStringSchema, finiteNumberSchema]);
11
+ export const sendAtSchema = z
12
+ .union([finiteNumberSchema, z.date()])
13
+ .transform((value) => value instanceof Date ? Math.floor(value.getTime() / 1_000) : value);
14
+ export const abortSignalSchema = z.custom((value) => typeof value === "object" &&
15
+ value !== null &&
16
+ typeof value.aborted === "boolean");
17
+ const functionSchema = z.custom((value) => typeof value === "function");
18
+ const retryPolicySchema = z
19
+ .object({
20
+ maxAttempts: positiveIntegerSchema,
21
+ initialDelayMs: finiteNumberSchema.nonnegative().optional(),
22
+ maxDelayMs: finiteNumberSchema.nonnegative().optional(),
23
+ backoffMultiplier: finiteNumberSchema.min(1).optional(),
24
+ retryOn: functionSchema.optional(),
25
+ sleep: functionSchema.optional(),
26
+ })
27
+ .loose()
28
+ .transform((value) => value);
29
+ const transportOptionsSchema = z
30
+ .object({
31
+ timeoutMs: positiveIntegerSchema.optional(),
32
+ fetcher: z.custom((value) => typeof value === "function").optional(),
33
+ baseUrl: z.string().url().optional(),
34
+ defaultHeaders: z.record(z.string(), z.string()).optional(),
35
+ retry: retryPolicySchema.optional(),
36
+ })
37
+ .partial()
38
+ .loose();
39
+ export const kavenegarOptionsSchema = transportOptionsSchema.extend({
40
+ apiKey: nonBlankStringSchema,
41
+ sender: nonBlankStringSchema.optional(),
42
+ });
43
+ export const smsIrOptionsSchema = transportOptionsSchema.extend({
44
+ apiKey: nonBlankStringSchema,
45
+ lineNumber: z.union([nonBlankStringSchema, finiteNumberSchema]),
46
+ });
47
+ export const smsMessageSchema = z
48
+ .object({
49
+ recipient: nonBlankStringSchema,
50
+ message: nonBlankStringSchema,
51
+ sender: nonBlankStringSchema.optional(),
52
+ sendAt: sendAtSchema.optional(),
53
+ localId: localIdSchema.optional(),
54
+ tag: z.string().optional(),
55
+ signal: abortSignalSchema.optional(),
56
+ })
57
+ .loose();
58
+ export const smsBulkMessageSchema = z
59
+ .object({
60
+ recipients: z.array(nonBlankStringSchema).min(1),
61
+ message: nonBlankStringSchema,
62
+ sender: nonBlankStringSchema.optional(),
63
+ sendAt: sendAtSchema.optional(),
64
+ signal: abortSignalSchema.optional(),
65
+ })
66
+ .loose();
67
+ export const smsIrMessageSchema = z
68
+ .object({
69
+ recipient: nonBlankStringSchema,
70
+ message: nonBlankStringSchema,
71
+ sendAt: sendAtSchema.optional(),
72
+ signal: abortSignalSchema.optional(),
73
+ })
74
+ .strict();
75
+ export const smsIrBulkMessageSchema = z
76
+ .object({
77
+ recipients: z.array(nonBlankStringSchema).min(1),
78
+ message: nonBlankStringSchema,
79
+ sendAt: sendAtSchema.optional(),
80
+ signal: abortSignalSchema.optional(),
81
+ })
82
+ .strict();
83
+ export const smsBatchMessageSchema = z
84
+ .object({
85
+ recipient: nonBlankStringSchema,
86
+ message: nonBlankStringSchema,
87
+ sender: nonBlankStringSchema.optional(),
88
+ sendAt: sendAtSchema.optional(),
89
+ localId: localIdSchema.optional(),
90
+ signal: abortSignalSchema.optional(),
91
+ })
92
+ .loose();
93
+ export const kavenegarSendArrayMessageSchema = z
94
+ .object({
95
+ recipient: nonBlankStringSchema,
96
+ message: nonBlankStringSchema,
97
+ sender: nonBlankStringSchema.optional(),
98
+ })
99
+ .strict();
100
+ export const signalOptionsSchema = z
101
+ .object({ signal: abortSignalSchema.optional() })
102
+ .loose();
103
+ export const idsInputSchema = z.array(localIdSchema).min(1);
104
+ export const cancellationInputSchema = z.object({ ids: idsInputSchema }).loose();
105
+ export const deliveryStatusQuerySchema = z
106
+ .object({
107
+ messageIds: idsInputSchema,
108
+ signal: abortSignalSchema.optional(),
109
+ })
110
+ .loose();
111
+ export const kavenegarTemplateSchema = z
112
+ .object({
113
+ recipient: nonBlankStringSchema,
114
+ template: nonBlankStringSchema,
115
+ parameters: z.array(z.string()).min(1).max(3),
116
+ signal: abortSignalSchema.optional(),
117
+ })
118
+ .loose();
119
+ export const kavenegarReceiveQuerySchema = z
120
+ .object({
121
+ lineNumber: nonBlankStringSchema,
122
+ isRead: z.boolean(),
123
+ signal: abortSignalSchema.optional(),
124
+ })
125
+ .loose();
126
+ export const kavenegarCountQuerySchema = z
127
+ .object({
128
+ startDate: nonNegativeIntegerSchema,
129
+ endDate: nonNegativeIntegerSchema.optional(),
130
+ lineNumber: nonBlankStringSchema.optional(),
131
+ isRead: z.boolean().optional(),
132
+ signal: abortSignalSchema.optional(),
133
+ })
134
+ .loose();
135
+ export const kavenegarSearchQuerySchema = z
136
+ .object({
137
+ messageIds: idsInputSchema.optional(),
138
+ startDate: nonNegativeIntegerSchema,
139
+ endDate: nonNegativeIntegerSchema.optional(),
140
+ lineNumber: nonBlankStringSchema.optional(),
141
+ page: positiveIntegerSchema.optional(),
142
+ pageSize: positiveIntegerSchema.optional(),
143
+ signal: abortSignalSchema.optional(),
144
+ })
145
+ .loose();
146
+ export const smsIrTemplateSchema = z
147
+ .object({
148
+ recipient: nonBlankStringSchema,
149
+ templateId: positiveIntegerSchema,
150
+ parameters: z.array(z.object({
151
+ name: nonBlankStringSchema,
152
+ value: z.string(),
153
+ })),
154
+ signal: abortSignalSchema.optional(),
155
+ })
156
+ .loose();
157
+ export const smsIrLikeToLikeSchema = z
158
+ .object({
159
+ recipients: z.array(nonBlankStringSchema).min(1),
160
+ messages: z.array(nonBlankStringSchema).min(1),
161
+ sendAt: sendAtSchema.optional(),
162
+ signal: abortSignalSchema.optional(),
163
+ })
164
+ .refine((value) => value.recipients.length === value.messages.length, {
165
+ message: "Recipients and messages must have equal lengths",
166
+ path: ["messages"],
167
+ })
168
+ .loose();
169
+ export const packQuerySchema = z
170
+ .object({
171
+ pageNumber: positiveIntegerSchema.optional(),
172
+ pageSize: positiveIntegerSchema.optional(),
173
+ signal: abortSignalSchema.optional(),
174
+ })
175
+ .loose();
176
+ export function formatZodIssues(error) {
177
+ return error.issues
178
+ .map((issue) => {
179
+ const path = issue.path.length === 0 ? "input" : issue.path.join(".");
180
+ return `${path}: ${issue.message}`;
181
+ })
182
+ .join("; ");
183
+ }
184
+ export function parseInput(schema, value, createError) {
185
+ const result = schema.safeParse(value);
186
+ if (!result.success) {
187
+ throw createError(`Invalid input: ${formatZodIssues(result.error)}`, result.error);
188
+ }
189
+ return result.data;
190
+ }
191
+ //# sourceMappingURL=schemas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../src/validation/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,mFAAmF;AACnF,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AAE1F,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,CAAC;AACtD,MAAM,CAAC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pC,CAAC,CAAC;SACD,IAAI,CAAC,IAAI,CAAC,CAAC;AACd,CAAC;AAED,MAAM,UAAU,UAAU,CACzB,MAAe,EACf,KAAc,EACd,WAA0D;IAE1D,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACvC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACrB,MAAM,WAAW,CAAC,kBAAkB,eAAe,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;IACpF,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC;AACpB,CAAC"}
@@ -0,0 +1,73 @@
1
+ # Architecture
2
+
3
+ `@mhbdev/sms` is organized as a small provider-adapter library. The public
4
+ contracts describe capabilities without requiring callers to depend on a
5
+ provider's transport or response format.
6
+
7
+ ## Layers
8
+
9
+ 1. **Contracts** (`src/contracts`)
10
+
11
+ Provider-neutral messages, results, capability interfaces, and provider
12
+ configuration types live here. Provider-specific request fields remain in
13
+ provider contracts so they can stay type-safe without weakening the shared
14
+ interfaces.
15
+
16
+ 2. **Transport** (`src/transport`)
17
+
18
+ `SmsHttpTransport` owns injected `fetch`, timeout cancellation, default
19
+ headers, abort propagation, and opt-in retry behavior. Providers pass it
20
+ already validated requests and remain responsible for provider endpoint
21
+ paths and body formats.
22
+
23
+ 3. **Provider adapters** (`src/providers`)
24
+
25
+ Provider classes validate inputs with Zod, build endpoint-specific requests,
26
+ invoke the shared transport, and expose the provider capabilities. They do
27
+ not expose API keys or provider response objects directly to callers.
28
+
29
+ 4. **Response parsers** (`src/providers/*/*-api.ts`)
30
+
31
+ Parsers validate successful and failed payloads with Zod, normalize provider
32
+ fields into public results, and preserve provider status metadata. Malformed
33
+ successful responses are treated as provider errors rather than silently
34
+ returning partial data. Zod issues are retained as causes, while public error
35
+ messages never include API keys or SMS content.
36
+
37
+ 5. **Errors** (`src/errors`)
38
+
39
+ Provider, validation, and transport errors share stable metadata such as
40
+ error codes, causes, HTTP status, provider status, and retry information.
41
+
42
+ ## Request lifecycle
43
+
44
+ ```text
45
+ public capability method
46
+ |
47
+ v
48
+ provider validation + request construction
49
+ |
50
+ v
51
+ SmsHttpTransport (fetch, timeout, abort, optional retry)
52
+ |
53
+ v
54
+ provider response parser
55
+ |
56
+ v
57
+ normalized public result or typed provider error
58
+ ```
59
+
60
+ Retries are disabled by default because a retried SMS request can create a
61
+ duplicate paid message. Applications must explicitly configure bounded retry
62
+ behavior and should use provider idempotency/local-ID features where available.
63
+
64
+ ## Compatibility boundary
65
+
66
+ The root package and the `/kavenegar` and `/sms-ir` subpaths are public entry
67
+ points. Legacy names, including `SmsIrSmsProvider` and the Kavenegar parser and
68
+ error exports, are retained deliberately. Internal refactors must validate
69
+ these entrypoints with TypeScript import tests and package-tarball smoke tests.
70
+
71
+ Capability mismatches between providers are documented rather than hidden by
72
+ the shared interfaces. Redesigning those contracts is a separate migration
73
+ task and should not be bundled with structural refactors.
@@ -0,0 +1,27 @@
1
+ # Capability matrix
2
+
3
+ The package keeps the portable contracts small and exposes provider-specific
4
+ operations on the concrete clients where the upstream APIs differ.
5
+
6
+ | Capability | Kavenegar | SMS.ir |
7
+ | --- | --- | --- |
8
+ | Raw message | `sendMessage` | `sendMessage` |
9
+ | Template/verify | `sendTemplate` with ordered tokens | `sendTemplate` with numeric template ID and named parameters |
10
+ | Bulk delivery | `sendBulk` | `sendBulk` |
11
+ | Per-recipient delivery | `sendArray` | `sendLikeToLike` |
12
+ | Scheduling | `sendAt` on raw/bulk messages | `sendAt` on bulk/like-to-like messages |
13
+ | Scheduled cancellation | `SmsMessageScheduler.cancelScheduled` by message IDs | `SmsPackScheduler.cancelScheduledPack` by pack ID; `cancelScheduled` remains as a compatibility alias |
14
+ | Delivery status | `getDeliveryStatus`, `getStatusByLocalId` | `getMessageStatus`, `getDeliveryStatus` |
15
+ | Outbound reporting | `getSentMessages`, `listSentMessages`, `getLatestSentMessages`, `countSentMessages` | `listPacks`, `getPack` |
16
+ | Inbound SMS | `getReceivedMessages`, `countReceivedMessages` | Not provided by the documented REST surface |
17
+
18
+ All provider clients accept an injected `fetcher`, timeout, custom base URL,
19
+ additional headers, and an optional retry policy. Retry is disabled unless
20
+ `retry.maxAttempts` is explicitly configured.
21
+
22
+ The capability contracts are generic. This keeps provider-specific request and
23
+ result types precise while allowing shared code to depend on
24
+ `SmsMessageSender`, `SmsTemplateSender`, `SmsBulkSender`,
25
+ `SmsDeliveryStatusReader`, `SmsMessageScheduler`, or `SmsPackScheduler` as
26
+ appropriate. SMS.ir raw and bulk inputs deliberately omit Kavenegar-only
27
+ `sender`, `localId`, and `tag` fields; Zod rejects those fields at runtime too.
@@ -0,0 +1,39 @@
1
+ # Migration from `@dordoone/sms`
2
+
3
+ The standalone package preserves the original provider-neutral types and the
4
+ Kavenegar adapter shape.
5
+
6
+ ## Package name
7
+
8
+ ```sh
9
+ npm uninstall @dordoone/sms
10
+ npm install @mhbdev/sms
11
+ ```
12
+
13
+ Replace imports from `@dordoone/sms` with `@mhbdev/sms`. Existing root exports
14
+ remain available, including:
15
+
16
+ - `SmsMessage`
17
+ - `SmsTemplateMessage`
18
+ - `SmsMessageSender`
19
+ - `SmsTemplateSender`
20
+ - `SmsSendResult`
21
+ - `KavenegarSmsProvider`
22
+ - `KavenegarError`
23
+ - `SmsProviderError`
24
+ - `parseKavenegarResponse`
25
+
26
+ Provider-specific imports can be made explicit:
27
+
28
+ ```ts
29
+ import { KavenegarSmsProvider } from "@mhbdev/sms/kavenegar";
30
+ import { SmsIrProvider } from "@mhbdev/sms/sms-ir";
31
+ ```
32
+
33
+ The Kavenegar client still converts Iranian `+98` recipients to the local
34
+ provider format, preserves injected fetchers, applies a 10-second default
35
+ timeout, and rejects malformed successful responses.
36
+
37
+ Kavenegar also supports a default `sender` option and per-message sender
38
+ overrides for raw, bulk, and send-array requests. SMS.ir uses `lineNumber`
39
+ instead; its raw and bulk inputs reject unsupported sender/local-id/tag fields.
package/package.json CHANGED
@@ -1,6 +1,86 @@
1
1
  {
2
- "name": "@mhbdev/sms",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
2
+ "name": "@mhbdev/sms",
3
+ "version": "0.2.0",
4
+ "description": "Provider-neutral SMS delivery clients for Kavenegar and SMS.ir.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "main": "./dist/index.js",
8
+ "module": "./dist/index.js",
9
+ "types": "./dist/index.d.ts",
10
+ "sideEffects": false,
11
+ "engines": {
12
+ "node": ">=20"
13
+ },
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/mhbdev/sms.git"
17
+ },
18
+ "bugs": {
19
+ "url": "https://github.com/mhbdev/sms/issues"
20
+ },
21
+ "homepage": "https://github.com/mhbdev/sms#readme",
22
+ "keywords": [
23
+ "sms",
24
+ "sms.ir",
25
+ "kavenegar",
26
+ "iran",
27
+ "typescript",
28
+ "otp"
29
+ ],
30
+ "files": [
31
+ "dist",
32
+ "README.md",
33
+ "LICENSE",
34
+ "CHANGELOG.md",
35
+ "docs"
36
+ ],
37
+ "exports": {
38
+ ".": {
39
+ "types": "./dist/index.d.ts",
40
+ "import": "./dist/index.js",
41
+ "default": "./dist/index.js"
42
+ },
43
+ "./kavenegar": {
44
+ "types": "./dist/kavenegar.d.ts",
45
+ "import": "./dist/kavenegar.js",
46
+ "default": "./dist/kavenegar.js"
47
+ },
48
+ "./sms-ir": {
49
+ "types": "./dist/sms-ir.d.ts",
50
+ "import": "./dist/sms-ir.js",
51
+ "default": "./dist/sms-ir.js"
52
+ },
53
+ "./package.json": "./package.json"
54
+ },
55
+ "publishConfig": {
56
+ "access": "public",
57
+ "provenance": true
58
+ },
59
+ "scripts": {
60
+ "build": "tsc -p tsconfig.build.json",
61
+ "clean": "node -e \"import('node:fs/promises').then(({rm}) => rm('dist', {recursive:true, force:true}))\"",
62
+ "typecheck": "tsc --noEmit",
63
+ "test": "vitest run",
64
+ "test:integration": "vitest run test/integration --passWithNoTests",
65
+ "test:watch": "vitest",
66
+ "lint": "biome check .",
67
+ "format": "biome format --write .",
68
+ "audit": "npm audit --audit-level=high && npm audit --omit=dev --audit-level=high && npm audit signatures",
69
+ "pack:check": "npm run build && publint && attw --pack --profile esm-only --quiet && npm pack --dry-run",
70
+ "version": "changeset version",
71
+ "release": "changeset publish"
72
+ },
73
+ "devDependencies": {
74
+ "@arethetypeswrong/cli": "^0.18.2",
75
+ "@biomejs/biome": "^2.5.6",
76
+ "@changesets/changelog-github": "^1.0.1",
77
+ "@changesets/cli": "^3.0.3",
78
+ "@types/node": "26.6.4",
79
+ "publint": "^0.3.25",
80
+ "typescript": "7.0.2",
81
+ "vitest": "^4.1.11"
82
+ },
83
+ "dependencies": {
84
+ "zod": "4.6.5"
85
+ }
86
+ }