@k-msg/core 0.1.5 → 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/README.md +23 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +25 -25
- package/dist/index.js.map +5 -4
- package/dist/index.mjs +25 -25
- package/dist/index.mjs.map +5 -4
- package/dist/platform.d.ts +20 -10
- package/dist/router/round-robin-router-provider.d.ts +20 -0
- package/dist/types/balance.d.ts +12 -0
- package/dist/types/history.d.ts +31 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/platform.d.ts +19 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -17,6 +17,9 @@ bun add @k-msg/core
|
|
|
17
17
|
- **Provider Management**: Multi-provider support and switching
|
|
18
18
|
- **Feature Flags**: Configurable platform capabilities
|
|
19
19
|
|
|
20
|
+
### 🔁 **Provider Rotation**
|
|
21
|
+
- **RoundRobinRouterProvider**: Rotate across multiple upstream providers (round-robin)
|
|
22
|
+
|
|
20
23
|
### ⚠️ **Comprehensive Error Handling**
|
|
21
24
|
- **KMessageError Hierarchy**: Structured error types for different scenarios
|
|
22
25
|
- **Error Context**: Rich error information with operation context
|
|
@@ -59,6 +62,25 @@ const health = await platform.healthCheck();
|
|
|
59
62
|
console.log(`Health: ${health.status}, Services: ${Object.keys(health.services).length}`);
|
|
60
63
|
```
|
|
61
64
|
|
|
65
|
+
### Round-robin Provider Rotation
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
import { RoundRobinRouterProvider, type BaseProvider } from "@k-msg/core";
|
|
69
|
+
|
|
70
|
+
const router = new RoundRobinRouterProvider({
|
|
71
|
+
id: "router",
|
|
72
|
+
providers: [providerA, providerB] satisfies BaseProvider[],
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
await router.send({
|
|
76
|
+
channel: "SMS",
|
|
77
|
+
templateCode: "SMS_DIRECT",
|
|
78
|
+
phoneNumber: "01012345678",
|
|
79
|
+
variables: {},
|
|
80
|
+
text: "hello",
|
|
81
|
+
});
|
|
82
|
+
```
|
|
83
|
+
|
|
62
84
|
### Error Handling Patterns
|
|
63
85
|
|
|
64
86
|
```typescript
|
|
@@ -284,4 +306,4 @@ See the main [CONTRIBUTING.md](../../CONTRIBUTING.md) for guidelines.
|
|
|
284
306
|
|
|
285
307
|
## License
|
|
286
308
|
|
|
287
|
-
MIT License - see [LICENSE](../../LICENSE) for details.
|
|
309
|
+
MIT License - see [LICENSE](../../LICENSE) for details.
|
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export * from "./provider";
|
|
|
7
7
|
export * from "./provider-registry";
|
|
8
8
|
export * from "./resilience/index";
|
|
9
9
|
export * from "./result";
|
|
10
|
+
export * from "./router/round-robin-router-provider";
|
|
10
11
|
export * from "./test-utils";
|
|
11
12
|
export * from "./types/index";
|
|
12
13
|
export * from "./universal-provider";
|