@k-msg/core 0.16.0 → 0.18.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 +2 -3
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -44
- package/dist/index.js.map +6 -81
- package/dist/index.mjs +3 -44
- package/dist/index.mjs.map +6 -81
- package/dist/persistence/repository.d.ts +11 -0
- package/dist/provider.d.ts +4 -1
- package/dist/resilience/index.d.ts +0 -3
- package/dist/runtime/env.d.ts +11 -0
- package/dist/types/index.d.ts +0 -1
- package/package.json +3 -3
- package/dist/config.d.ts +0 -206
- package/dist/health.d.ts +0 -39
- package/dist/resilience/error-recovery.d.ts +0 -20
- package/dist/resilience/graceful-degradation.d.ts +0 -12
- package/dist/resilience/health-monitor.d.ts +0 -20
- package/dist/types/history.d.ts +0 -40
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { KMsgError } from "../errors";
|
|
2
|
+
import type { Result } from "../result";
|
|
3
|
+
import type { SendInput, SendResult } from "../types/message";
|
|
4
|
+
export type PersistenceStrategy = "none" | "log" | "queue" | "full";
|
|
5
|
+
export interface MessageRepository {
|
|
6
|
+
save(input: SendInput, options?: {
|
|
7
|
+
strategy?: PersistenceStrategy;
|
|
8
|
+
}): Promise<Result<string, KMsgError>>;
|
|
9
|
+
update(messageId: string, result: Partial<SendResult>): Promise<Result<void, KMsgError>>;
|
|
10
|
+
find(messageId: string): Promise<Result<SendResult | null, KMsgError>>;
|
|
11
|
+
}
|
package/dist/provider.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { KMsgError } from "./errors";
|
|
2
2
|
import type { Result } from "./result";
|
|
3
|
-
import type { DeliveryStatusQuery, DeliveryStatusResult, KakaoChannel, KakaoChannelCategories, MessageType, ProviderOnboardingSpec, SendOptions, SendResult } from "./types/index";
|
|
3
|
+
import type { BalanceQuery, BalanceResult, DeliveryStatusQuery, DeliveryStatusResult, KakaoChannel, KakaoChannelCategories, MessageType, ProviderOnboardingSpec, SendOptions, SendResult } from "./types/index";
|
|
4
4
|
export interface Template {
|
|
5
5
|
id: string;
|
|
6
6
|
code: string;
|
|
@@ -64,6 +64,9 @@ export interface ProviderHealthStatus {
|
|
|
64
64
|
latencyMs?: number;
|
|
65
65
|
data?: Record<string, unknown>;
|
|
66
66
|
}
|
|
67
|
+
export interface BalanceProvider {
|
|
68
|
+
getBalance(query?: BalanceQuery): Promise<Result<BalanceResult, KMsgError>>;
|
|
69
|
+
}
|
|
67
70
|
export interface Provider {
|
|
68
71
|
readonly id: string;
|
|
69
72
|
readonly name: string;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
export { BulkOperationHandler, type BulkOperationOptions, } from "./bulk-operation";
|
|
2
2
|
export { CircuitBreaker, type CircuitBreakerOptions } from "./circuit-breaker";
|
|
3
|
-
export { ErrorRecovery } from "./error-recovery";
|
|
4
|
-
export { GracefulDegradation } from "./graceful-degradation";
|
|
5
|
-
export { HealthMonitor } from "./health-monitor";
|
|
6
3
|
export { RateLimiter } from "./rate-limiter";
|
|
7
4
|
export { RetryHandler, type RetryOptions } from "./retry-handler";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type RuntimeEnvRecord = Record<string, string | undefined>;
|
|
2
|
+
/**
|
|
3
|
+
* Resolve environment variables in a runtime-neutral order.
|
|
4
|
+
*
|
|
5
|
+
* Priority:
|
|
6
|
+
* 1. globalThis.__K_MSG_ENV__
|
|
7
|
+
* 2. globalThis.__ENV__
|
|
8
|
+
* 3. globalThis.process?.env
|
|
9
|
+
*/
|
|
10
|
+
export declare function getRuntimeEnvSource(): RuntimeEnvRecord;
|
|
11
|
+
export declare function readRuntimeEnv(key: string): string | undefined;
|
package/dist/types/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@k-msg/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"packageManager": "bun@1.3.8",
|
|
5
5
|
"description": "Core types and interfaces for K-Message platform",
|
|
6
6
|
"type": "module",
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"zod": "^4.0.14"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@types/bun": "
|
|
42
|
-
"typescript": "^5.
|
|
41
|
+
"@types/bun": "^1.3.9",
|
|
42
|
+
"typescript": "^5.7.2"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {},
|
|
45
45
|
"files": [
|
package/dist/config.d.ts
DELETED
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { LogLevel } from "./logger";
|
|
3
|
-
export declare const DatabaseConfigSchema: z.ZodObject<{
|
|
4
|
-
host: z.ZodDefault<z.ZodString>;
|
|
5
|
-
port: z.ZodDefault<z.ZodNumber>;
|
|
6
|
-
database: z.ZodString;
|
|
7
|
-
username: z.ZodString;
|
|
8
|
-
password: z.ZodString;
|
|
9
|
-
ssl: z.ZodDefault<z.ZodBoolean>;
|
|
10
|
-
maxConnections: z.ZodDefault<z.ZodNumber>;
|
|
11
|
-
connectionTimeout: z.ZodDefault<z.ZodNumber>;
|
|
12
|
-
}, z.core.$strip>;
|
|
13
|
-
export declare const RedisConfigSchema: z.ZodObject<{
|
|
14
|
-
host: z.ZodDefault<z.ZodString>;
|
|
15
|
-
port: z.ZodDefault<z.ZodNumber>;
|
|
16
|
-
password: z.ZodOptional<z.ZodString>;
|
|
17
|
-
db: z.ZodDefault<z.ZodNumber>;
|
|
18
|
-
keyPrefix: z.ZodDefault<z.ZodString>;
|
|
19
|
-
maxRetries: z.ZodDefault<z.ZodNumber>;
|
|
20
|
-
}, z.core.$strip>;
|
|
21
|
-
export declare const LoggerConfigSchema: z.ZodObject<{
|
|
22
|
-
level: z.ZodDefault<z.ZodEnum<typeof LogLevel>>;
|
|
23
|
-
enableConsole: z.ZodDefault<z.ZodBoolean>;
|
|
24
|
-
enableFile: z.ZodDefault<z.ZodBoolean>;
|
|
25
|
-
filePath: z.ZodOptional<z.ZodString>;
|
|
26
|
-
maxFileSize: z.ZodDefault<z.ZodNumber>;
|
|
27
|
-
maxFiles: z.ZodDefault<z.ZodNumber>;
|
|
28
|
-
enableJson: z.ZodDefault<z.ZodBoolean>;
|
|
29
|
-
enableColors: z.ZodDefault<z.ZodBoolean>;
|
|
30
|
-
}, z.core.$strip>;
|
|
31
|
-
export declare const HealthConfigSchema: z.ZodObject<{
|
|
32
|
-
timeout: z.ZodDefault<z.ZodNumber>;
|
|
33
|
-
interval: z.ZodDefault<z.ZodNumber>;
|
|
34
|
-
retries: z.ZodDefault<z.ZodNumber>;
|
|
35
|
-
includeMetrics: z.ZodDefault<z.ZodBoolean>;
|
|
36
|
-
}, z.core.$strip>;
|
|
37
|
-
export declare const IWINVConfigSchema: z.ZodObject<{
|
|
38
|
-
apiKey: z.ZodString;
|
|
39
|
-
timeout: z.ZodDefault<z.ZodNumber>;
|
|
40
|
-
retryAttempts: z.ZodDefault<z.ZodNumber>;
|
|
41
|
-
retryDelay: z.ZodDefault<z.ZodNumber>;
|
|
42
|
-
debug: z.ZodDefault<z.ZodBoolean>;
|
|
43
|
-
rateLimit: z.ZodDefault<z.ZodObject<{
|
|
44
|
-
requests: z.ZodDefault<z.ZodNumber>;
|
|
45
|
-
perSecond: z.ZodDefault<z.ZodNumber>;
|
|
46
|
-
}, z.core.$strip>>;
|
|
47
|
-
}, z.core.$strip>;
|
|
48
|
-
export declare const SMSConfigSchema: z.ZodObject<{
|
|
49
|
-
provider: z.ZodEnum<{
|
|
50
|
-
iwinv: "iwinv";
|
|
51
|
-
aligo: "aligo";
|
|
52
|
-
solapi: "solapi";
|
|
53
|
-
coolsms: "coolsms";
|
|
54
|
-
}>;
|
|
55
|
-
apiKey: z.ZodString;
|
|
56
|
-
apiSecret: z.ZodOptional<z.ZodString>;
|
|
57
|
-
senderId: z.ZodString;
|
|
58
|
-
defaultCountryCode: z.ZodDefault<z.ZodString>;
|
|
59
|
-
timeout: z.ZodDefault<z.ZodNumber>;
|
|
60
|
-
}, z.core.$strip>;
|
|
61
|
-
export declare const ServerConfigSchema: z.ZodObject<{
|
|
62
|
-
port: z.ZodDefault<z.ZodNumber>;
|
|
63
|
-
host: z.ZodDefault<z.ZodString>;
|
|
64
|
-
cors: z.ZodDefault<z.ZodObject<{
|
|
65
|
-
origins: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
66
|
-
credentials: z.ZodDefault<z.ZodBoolean>;
|
|
67
|
-
}, z.core.$strip>>;
|
|
68
|
-
maxRequestSize: z.ZodDefault<z.ZodNumber>;
|
|
69
|
-
requestTimeout: z.ZodDefault<z.ZodNumber>;
|
|
70
|
-
enableMetrics: z.ZodDefault<z.ZodBoolean>;
|
|
71
|
-
enableDocs: z.ZodDefault<z.ZodBoolean>;
|
|
72
|
-
}, z.core.$strip>;
|
|
73
|
-
export declare const QueueConfigSchema: z.ZodObject<{
|
|
74
|
-
maxConcurrency: z.ZodDefault<z.ZodNumber>;
|
|
75
|
-
maxRetries: z.ZodDefault<z.ZodNumber>;
|
|
76
|
-
retryDelay: z.ZodDefault<z.ZodNumber>;
|
|
77
|
-
maxAge: z.ZodDefault<z.ZodNumber>;
|
|
78
|
-
batchSize: z.ZodDefault<z.ZodNumber>;
|
|
79
|
-
processingInterval: z.ZodDefault<z.ZodNumber>;
|
|
80
|
-
}, z.core.$strip>;
|
|
81
|
-
export declare const KMessageConfigSchema: z.ZodObject<{
|
|
82
|
-
environment: z.ZodDefault<z.ZodEnum<{
|
|
83
|
-
development: "development";
|
|
84
|
-
staging: "staging";
|
|
85
|
-
production: "production";
|
|
86
|
-
}>>;
|
|
87
|
-
server: z.ZodDefault<z.ZodObject<{
|
|
88
|
-
port: z.ZodDefault<z.ZodNumber>;
|
|
89
|
-
host: z.ZodDefault<z.ZodString>;
|
|
90
|
-
cors: z.ZodDefault<z.ZodObject<{
|
|
91
|
-
origins: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
92
|
-
credentials: z.ZodDefault<z.ZodBoolean>;
|
|
93
|
-
}, z.core.$strip>>;
|
|
94
|
-
maxRequestSize: z.ZodDefault<z.ZodNumber>;
|
|
95
|
-
requestTimeout: z.ZodDefault<z.ZodNumber>;
|
|
96
|
-
enableMetrics: z.ZodDefault<z.ZodBoolean>;
|
|
97
|
-
enableDocs: z.ZodDefault<z.ZodBoolean>;
|
|
98
|
-
}, z.core.$strip>>;
|
|
99
|
-
database: z.ZodOptional<z.ZodObject<{
|
|
100
|
-
host: z.ZodDefault<z.ZodString>;
|
|
101
|
-
port: z.ZodDefault<z.ZodNumber>;
|
|
102
|
-
database: z.ZodString;
|
|
103
|
-
username: z.ZodString;
|
|
104
|
-
password: z.ZodString;
|
|
105
|
-
ssl: z.ZodDefault<z.ZodBoolean>;
|
|
106
|
-
maxConnections: z.ZodDefault<z.ZodNumber>;
|
|
107
|
-
connectionTimeout: z.ZodDefault<z.ZodNumber>;
|
|
108
|
-
}, z.core.$strip>>;
|
|
109
|
-
redis: z.ZodOptional<z.ZodObject<{
|
|
110
|
-
host: z.ZodDefault<z.ZodString>;
|
|
111
|
-
port: z.ZodDefault<z.ZodNumber>;
|
|
112
|
-
password: z.ZodOptional<z.ZodString>;
|
|
113
|
-
db: z.ZodDefault<z.ZodNumber>;
|
|
114
|
-
keyPrefix: z.ZodDefault<z.ZodString>;
|
|
115
|
-
maxRetries: z.ZodDefault<z.ZodNumber>;
|
|
116
|
-
}, z.core.$strip>>;
|
|
117
|
-
logger: z.ZodDefault<z.ZodObject<{
|
|
118
|
-
level: z.ZodDefault<z.ZodEnum<typeof LogLevel>>;
|
|
119
|
-
enableConsole: z.ZodDefault<z.ZodBoolean>;
|
|
120
|
-
enableFile: z.ZodDefault<z.ZodBoolean>;
|
|
121
|
-
filePath: z.ZodOptional<z.ZodString>;
|
|
122
|
-
maxFileSize: z.ZodDefault<z.ZodNumber>;
|
|
123
|
-
maxFiles: z.ZodDefault<z.ZodNumber>;
|
|
124
|
-
enableJson: z.ZodDefault<z.ZodBoolean>;
|
|
125
|
-
enableColors: z.ZodDefault<z.ZodBoolean>;
|
|
126
|
-
}, z.core.$strip>>;
|
|
127
|
-
health: z.ZodDefault<z.ZodObject<{
|
|
128
|
-
timeout: z.ZodDefault<z.ZodNumber>;
|
|
129
|
-
interval: z.ZodDefault<z.ZodNumber>;
|
|
130
|
-
retries: z.ZodDefault<z.ZodNumber>;
|
|
131
|
-
includeMetrics: z.ZodDefault<z.ZodBoolean>;
|
|
132
|
-
}, z.core.$strip>>;
|
|
133
|
-
queue: z.ZodDefault<z.ZodObject<{
|
|
134
|
-
maxConcurrency: z.ZodDefault<z.ZodNumber>;
|
|
135
|
-
maxRetries: z.ZodDefault<z.ZodNumber>;
|
|
136
|
-
retryDelay: z.ZodDefault<z.ZodNumber>;
|
|
137
|
-
maxAge: z.ZodDefault<z.ZodNumber>;
|
|
138
|
-
batchSize: z.ZodDefault<z.ZodNumber>;
|
|
139
|
-
processingInterval: z.ZodDefault<z.ZodNumber>;
|
|
140
|
-
}, z.core.$strip>>;
|
|
141
|
-
providers: z.ZodDefault<z.ZodObject<{
|
|
142
|
-
iwinv: z.ZodOptional<z.ZodObject<{
|
|
143
|
-
apiKey: z.ZodString;
|
|
144
|
-
timeout: z.ZodDefault<z.ZodNumber>;
|
|
145
|
-
retryAttempts: z.ZodDefault<z.ZodNumber>;
|
|
146
|
-
retryDelay: z.ZodDefault<z.ZodNumber>;
|
|
147
|
-
debug: z.ZodDefault<z.ZodBoolean>;
|
|
148
|
-
rateLimit: z.ZodDefault<z.ZodObject<{
|
|
149
|
-
requests: z.ZodDefault<z.ZodNumber>;
|
|
150
|
-
perSecond: z.ZodDefault<z.ZodNumber>;
|
|
151
|
-
}, z.core.$strip>>;
|
|
152
|
-
}, z.core.$strip>>;
|
|
153
|
-
sms: z.ZodOptional<z.ZodObject<{
|
|
154
|
-
provider: z.ZodEnum<{
|
|
155
|
-
iwinv: "iwinv";
|
|
156
|
-
aligo: "aligo";
|
|
157
|
-
solapi: "solapi";
|
|
158
|
-
coolsms: "coolsms";
|
|
159
|
-
}>;
|
|
160
|
-
apiKey: z.ZodString;
|
|
161
|
-
apiSecret: z.ZodOptional<z.ZodString>;
|
|
162
|
-
senderId: z.ZodString;
|
|
163
|
-
defaultCountryCode: z.ZodDefault<z.ZodString>;
|
|
164
|
-
timeout: z.ZodDefault<z.ZodNumber>;
|
|
165
|
-
}, z.core.$strip>>;
|
|
166
|
-
}, z.core.$strip>>;
|
|
167
|
-
features: z.ZodDefault<z.ZodObject<{
|
|
168
|
-
enableBulkSending: z.ZodDefault<z.ZodBoolean>;
|
|
169
|
-
enableScheduling: z.ZodDefault<z.ZodBoolean>;
|
|
170
|
-
enableAnalytics: z.ZodDefault<z.ZodBoolean>;
|
|
171
|
-
enableWebhooks: z.ZodDefault<z.ZodBoolean>;
|
|
172
|
-
enableTemplateCache: z.ZodDefault<z.ZodBoolean>;
|
|
173
|
-
maxTemplatesPerProvider: z.ZodDefault<z.ZodNumber>;
|
|
174
|
-
maxRecipientsPerBatch: z.ZodDefault<z.ZodNumber>;
|
|
175
|
-
}, z.core.$strip>>;
|
|
176
|
-
security: z.ZodDefault<z.ZodObject<{
|
|
177
|
-
apiKeyRequired: z.ZodDefault<z.ZodBoolean>;
|
|
178
|
-
rateLimitEnabled: z.ZodDefault<z.ZodBoolean>;
|
|
179
|
-
maxRequestsPerMinute: z.ZodDefault<z.ZodNumber>;
|
|
180
|
-
enableCors: z.ZodDefault<z.ZodBoolean>;
|
|
181
|
-
trustedProxies: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
182
|
-
}, z.core.$strip>>;
|
|
183
|
-
}, z.core.$strip>;
|
|
184
|
-
export type DatabaseConfig = z.infer<typeof DatabaseConfigSchema>;
|
|
185
|
-
export type RedisConfig = z.infer<typeof RedisConfigSchema>;
|
|
186
|
-
export type ConfigLoggerConfig = z.infer<typeof LoggerConfigSchema>;
|
|
187
|
-
export type HealthConfig = z.infer<typeof HealthConfigSchema>;
|
|
188
|
-
export type IWINVConfig = z.infer<typeof IWINVConfigSchema>;
|
|
189
|
-
export type SMSConfig = z.infer<typeof SMSConfigSchema>;
|
|
190
|
-
export type ServerConfig = z.infer<typeof ServerConfigSchema>;
|
|
191
|
-
export type QueueConfig = z.infer<typeof QueueConfigSchema>;
|
|
192
|
-
export type KMessageConfig = z.infer<typeof KMessageConfigSchema>;
|
|
193
|
-
export declare class ConfigLoader {
|
|
194
|
-
static loadFromEnv(): KMessageConfig;
|
|
195
|
-
static loadFromFile(filePath: string): Promise<KMessageConfig>;
|
|
196
|
-
static validate(config: unknown): KMessageConfig;
|
|
197
|
-
static getDefaults(): KMessageConfig;
|
|
198
|
-
}
|
|
199
|
-
type DeepPartial<T> = {
|
|
200
|
-
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
|
|
201
|
-
};
|
|
202
|
-
export declare const developmentConfig: DeepPartial<KMessageConfig>;
|
|
203
|
-
export declare const productionConfig: DeepPartial<KMessageConfig>;
|
|
204
|
-
export declare function mergeConfigs(base: KMessageConfig, override: Partial<KMessageConfig>): KMessageConfig;
|
|
205
|
-
export declare function validateProviderConfig(provider: "iwinv" | "sms", config: unknown): IWINVConfig | SMSConfig;
|
|
206
|
-
export {};
|
package/dist/health.d.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
export interface HealthStatus {
|
|
2
|
-
healthy: boolean;
|
|
3
|
-
timestamp: Date;
|
|
4
|
-
uptime: number;
|
|
5
|
-
version?: string;
|
|
6
|
-
services?: Record<string, ServiceHealth>;
|
|
7
|
-
metrics?: Record<string, any>;
|
|
8
|
-
}
|
|
9
|
-
export interface ServiceHealth {
|
|
10
|
-
healthy: boolean;
|
|
11
|
-
latency?: number;
|
|
12
|
-
error?: string;
|
|
13
|
-
lastCheck?: Date;
|
|
14
|
-
}
|
|
15
|
-
export interface HealthCheckConfig {
|
|
16
|
-
timeout?: number;
|
|
17
|
-
interval?: number;
|
|
18
|
-
retries?: number;
|
|
19
|
-
includeMetrics?: boolean;
|
|
20
|
-
}
|
|
21
|
-
export declare class HealthChecker {
|
|
22
|
-
private config;
|
|
23
|
-
private startTime;
|
|
24
|
-
private services;
|
|
25
|
-
private lastCheck;
|
|
26
|
-
constructor(config?: HealthCheckConfig);
|
|
27
|
-
registerService(name: string, checkFn: () => Promise<ServiceHealth>): void;
|
|
28
|
-
unregisterService(name: string): boolean;
|
|
29
|
-
clearServices(): void;
|
|
30
|
-
checkHealth(): Promise<HealthStatus>;
|
|
31
|
-
getLastKnownStatus(): HealthStatus;
|
|
32
|
-
private timeoutPromise;
|
|
33
|
-
private calculateAverageLatency;
|
|
34
|
-
}
|
|
35
|
-
export declare class SimpleHealthChecker {
|
|
36
|
-
static database(): () => Promise<ServiceHealth>;
|
|
37
|
-
static external(url: string, timeout?: number): () => Promise<ServiceHealth>;
|
|
38
|
-
static memory(maxUsageMB?: number): () => Promise<ServiceHealth>;
|
|
39
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Error recovery utilities - combines multiple recovery patterns
|
|
3
|
-
*/
|
|
4
|
-
import { type CircuitBreakerOptions } from "./circuit-breaker";
|
|
5
|
-
import { type RetryOptions } from "./retry-handler";
|
|
6
|
-
export declare const ErrorRecovery: {
|
|
7
|
-
/**
|
|
8
|
-
* Create a resilient function that combines multiple recovery patterns
|
|
9
|
-
*/
|
|
10
|
-
createResilientFunction<T extends any[], R>(func: (...args: T) => Promise<R>, options?: {
|
|
11
|
-
retryOptions?: Partial<RetryOptions>;
|
|
12
|
-
circuitBreaker?: CircuitBreakerOptions;
|
|
13
|
-
rateLimiter?: {
|
|
14
|
-
maxRequests: number;
|
|
15
|
-
windowMs: number;
|
|
16
|
-
};
|
|
17
|
-
timeout?: number;
|
|
18
|
-
fallback?: (...args: T) => Promise<R>;
|
|
19
|
-
}): (...args: T) => Promise<R>;
|
|
20
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Graceful degradation handler
|
|
3
|
-
*/
|
|
4
|
-
import { type RetryOptions } from "./retry-handler";
|
|
5
|
-
export declare class GracefulDegradation {
|
|
6
|
-
private fallbackStrategies;
|
|
7
|
-
registerFallback<T>(operationName: string, fallbackFunction: () => Promise<T>): void;
|
|
8
|
-
executeWithFallback<T>(operationName: string, primaryOperation: () => Promise<T>, options?: {
|
|
9
|
-
timeout?: number;
|
|
10
|
-
retryOptions?: Partial<RetryOptions>;
|
|
11
|
-
}): Promise<T>;
|
|
12
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Health check monitor with automatic recovery
|
|
3
|
-
* Note: This is the resilience-layer health monitor.
|
|
4
|
-
* For the main health check system, see ../health.ts
|
|
5
|
-
*/
|
|
6
|
-
export declare class HealthMonitor {
|
|
7
|
-
private services;
|
|
8
|
-
private healthStatus;
|
|
9
|
-
private lastCheck;
|
|
10
|
-
private checkInterval;
|
|
11
|
-
private intervalId?;
|
|
12
|
-
constructor(services: Map<string, () => Promise<boolean>>, checkIntervalMs?: number);
|
|
13
|
-
start(): void;
|
|
14
|
-
stop(): void;
|
|
15
|
-
private checkAllServices;
|
|
16
|
-
getServiceHealth(serviceName: string): boolean | undefined;
|
|
17
|
-
getAllHealth(): Record<string, boolean>;
|
|
18
|
-
isServiceHealthy(serviceName: string): boolean;
|
|
19
|
-
getLastCheckTime(serviceName: string): number | undefined;
|
|
20
|
-
}
|
package/dist/types/history.d.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import type { MessageType } from "./message";
|
|
2
|
-
export type HistoryChannel = MessageType;
|
|
3
|
-
export interface HistoryQuery {
|
|
4
|
-
channel: HistoryChannel;
|
|
5
|
-
startDate: string | Date;
|
|
6
|
-
endDate: string | Date;
|
|
7
|
-
page?: number;
|
|
8
|
-
pageSize?: number;
|
|
9
|
-
/**
|
|
10
|
-
* Cursor key for providers that use cursor-based pagination (e.g. SOLAPI).
|
|
11
|
-
* When provided, it takes precedence over `page`.
|
|
12
|
-
*/
|
|
13
|
-
startKey?: string;
|
|
14
|
-
phone?: string;
|
|
15
|
-
requestNo?: string;
|
|
16
|
-
companyId?: string;
|
|
17
|
-
}
|
|
18
|
-
export interface HistoryItem {
|
|
19
|
-
providerId: string;
|
|
20
|
-
channel: HistoryChannel;
|
|
21
|
-
messageId: string;
|
|
22
|
-
to?: string;
|
|
23
|
-
from?: string;
|
|
24
|
-
status?: string;
|
|
25
|
-
statusCode?: string;
|
|
26
|
-
statusMessage?: string;
|
|
27
|
-
sentAt?: Date;
|
|
28
|
-
raw: unknown;
|
|
29
|
-
}
|
|
30
|
-
export interface HistoryResult {
|
|
31
|
-
providerId: string;
|
|
32
|
-
channel: HistoryChannel;
|
|
33
|
-
totalCount: number;
|
|
34
|
-
/**
|
|
35
|
-
* Cursor key for fetching the next page when provider supports cursor pagination.
|
|
36
|
-
*/
|
|
37
|
-
nextKey?: string | null;
|
|
38
|
-
items: HistoryItem[];
|
|
39
|
-
raw?: unknown;
|
|
40
|
-
}
|