@adaptic/lumic-utils 1.0.8 → 1.0.10

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 (87) hide show
  1. package/dist/{index-Cstek604.js → index-CcXQeJz8.js} +22 -182
  2. package/dist/index-CcXQeJz8.js.map +1 -0
  3. package/dist/{index-DZZCd-1T.js → index-CcgbRft2.js} +22 -182
  4. package/dist/index-CcgbRft2.js.map +1 -0
  5. package/dist/index.cjs +11417 -122
  6. package/dist/index.cjs.map +1 -1
  7. package/dist/index.mjs +11399 -39
  8. package/dist/index.mjs.map +1 -1
  9. package/dist/test.cjs +7 -24
  10. package/dist/test.cjs.map +1 -1
  11. package/dist/test.mjs +7 -24
  12. package/dist/test.mjs.map +1 -1
  13. package/dist/types/aws-types.ts +1 -1
  14. package/dist/types/functions/aws-lambda.d.ts +1 -1
  15. package/dist/types/functions/aws-s3-utils.d.ts +2 -2
  16. package/dist/types/functions/google-sheets.d.ts +4 -4
  17. package/dist/types/functions/json-llm-tools.d.ts +3 -25
  18. package/dist/types/functions/llm-call.d.ts +2 -2
  19. package/dist/types/functions/llm-deepseek.d.ts +1 -1
  20. package/dist/types/functions/llm-openai.d.ts +2 -3
  21. package/dist/types/functions/llm-utils.d.ts +1 -24
  22. package/dist/types/functions/slack-utils.d.ts +4 -3
  23. package/dist/types/functions/utils.d.ts +14 -2
  24. package/dist/types/functions/zip-utils.d.ts +10 -12
  25. package/dist/types/google-types.ts +3 -6
  26. package/dist/types/index.d.ts +0 -30
  27. package/dist/types/index.ts +1 -1
  28. package/dist/types/openai-types.ts +6 -165
  29. package/dist/types/types/aws-types.d.ts +1 -1
  30. package/dist/types/types/google-types.d.ts +3 -5
  31. package/dist/types/types/index.d.ts +1 -1
  32. package/dist/types/types/openai-types.d.ts +3 -149
  33. package/dist/types/utils/aws-initialise.d.ts +1 -6
  34. package/package.json +3 -2
  35. package/dist/apollo-client.client-DE7JUXjy.js +0 -3693
  36. package/dist/apollo-client.client-DE7JUXjy.js.map +0 -1
  37. package/dist/apollo-client.client-DlG4HsFm.js +0 -3704
  38. package/dist/apollo-client.client-DlG4HsFm.js.map +0 -1
  39. package/dist/apollo-client.server-D1QJea5_.js +0 -16319
  40. package/dist/apollo-client.server-D1QJea5_.js.map +0 -1
  41. package/dist/apollo-client.server-uqalq3yp.js +0 -16321
  42. package/dist/apollo-client.server-uqalq3yp.js.map +0 -1
  43. package/dist/index-Bd84zcTQ.js +0 -74944
  44. package/dist/index-Bd84zcTQ.js.map +0 -1
  45. package/dist/index-CZKOqrJ4.js +0 -75137
  46. package/dist/index-CZKOqrJ4.js.map +0 -1
  47. package/dist/index-CsKfs4nG.js +0 -12108
  48. package/dist/index-CsKfs4nG.js.map +0 -1
  49. package/dist/index-Cstek604.js.map +0 -1
  50. package/dist/index-DZZCd-1T.js.map +0 -1
  51. package/dist/index-aP9ow8_W.js +0 -12271
  52. package/dist/index-aP9ow8_W.js.map +0 -1
  53. package/dist/types/config/__tests__/secrets.test.d.ts +0 -1
  54. package/dist/types/config/secrets.d.ts +0 -186
  55. package/dist/types/errors/__tests__/errors.test.d.ts +0 -1
  56. package/dist/types/errors/index.d.ts +0 -77
  57. package/dist/types/functions/__tests__/aws-lambda.test.d.ts +0 -1
  58. package/dist/types/functions/__tests__/aws-s3-utils.test.d.ts +0 -1
  59. package/dist/types/functions/__tests__/json-llm-tools.test.d.ts +0 -1
  60. package/dist/types/functions/__tests__/json-tools.test.d.ts +0 -1
  61. package/dist/types/functions/__tests__/slack-utils.test.d.ts +0 -1
  62. package/dist/types/schemas/aws-schemas.d.ts +0 -210
  63. package/dist/types/schemas/google-sheets-schemas.d.ts +0 -32
  64. package/dist/types/schemas/index.d.ts +0 -17
  65. package/dist/types/schemas/openai-schemas.d.ts +0 -834
  66. package/dist/types/schemas/perplexity-schemas.d.ts +0 -338
  67. package/dist/types/schemas/validation-helpers.d.ts +0 -33
  68. package/dist/types/utils/__tests__/circuit-breaker.test.d.ts +0 -1
  69. package/dist/types/utils/__tests__/correlation.test.d.ts +0 -1
  70. package/dist/types/utils/__tests__/input-validator.test.d.ts +0 -1
  71. package/dist/types/utils/__tests__/llm-cost-tracker.test.d.ts +0 -1
  72. package/dist/types/utils/__tests__/logger.test.d.ts +0 -1
  73. package/dist/types/utils/__tests__/metrics.test.d.ts +0 -1
  74. package/dist/types/utils/__tests__/retry.test.d.ts +0 -1
  75. package/dist/types/utils/__tests__/sanitizer.test.d.ts +0 -1
  76. package/dist/types/utils/__tests__/timeouts.test.d.ts +0 -1
  77. package/dist/types/utils/circuit-breaker.d.ts +0 -99
  78. package/dist/types/utils/correlation.d.ts +0 -43
  79. package/dist/types/utils/health-check.d.ts +0 -50
  80. package/dist/types/utils/input-validator.d.ts +0 -51
  81. package/dist/types/utils/llm-cost-tracker.d.ts +0 -174
  82. package/dist/types/utils/logger.d.ts +0 -8
  83. package/dist/types/utils/metrics.d.ts +0 -61
  84. package/dist/types/utils/rate-limiter.d.ts +0 -85
  85. package/dist/types/utils/retry.d.ts +0 -58
  86. package/dist/types/utils/sanitizer.d.ts +0 -30
  87. package/dist/types/utils/timeouts.d.ts +0 -44
@@ -1,338 +0,0 @@
1
- import { z } from 'zod';
2
- /**
3
- * Zod schema for a complete Perplexity API response.
4
- * Validates the core fields that lumic-utils depends on.
5
- * Uses .passthrough() to allow additional fields from newer API versions.
6
- */
7
- export declare const perplexityResponseSchema: z.ZodObject<{
8
- id: z.ZodString;
9
- model: z.ZodString;
10
- object: z.ZodString;
11
- created: z.ZodNumber;
12
- choices: z.ZodArray<z.ZodObject<{
13
- index: z.ZodNumber;
14
- finish_reason: z.ZodNullable<z.ZodEnum<["stop", "length", "model_length"]>>;
15
- message: z.ZodObject<{
16
- role: z.ZodEnum<["assistant"]>;
17
- content: z.ZodString;
18
- }, "strip", z.ZodTypeAny, {
19
- role: "assistant";
20
- content: string;
21
- }, {
22
- role: "assistant";
23
- content: string;
24
- }>;
25
- delta: z.ZodOptional<z.ZodObject<{
26
- role: z.ZodOptional<z.ZodString>;
27
- content: z.ZodOptional<z.ZodString>;
28
- }, "strip", z.ZodTypeAny, {
29
- role?: string | undefined;
30
- content?: string | undefined;
31
- }, {
32
- role?: string | undefined;
33
- content?: string | undefined;
34
- }>>;
35
- }, "strip", z.ZodTypeAny, {
36
- message: {
37
- role: "assistant";
38
- content: string;
39
- };
40
- index: number;
41
- finish_reason: "length" | "stop" | "model_length" | null;
42
- delta?: {
43
- role?: string | undefined;
44
- content?: string | undefined;
45
- } | undefined;
46
- }, {
47
- message: {
48
- role: "assistant";
49
- content: string;
50
- };
51
- index: number;
52
- finish_reason: "length" | "stop" | "model_length" | null;
53
- delta?: {
54
- role?: string | undefined;
55
- content?: string | undefined;
56
- } | undefined;
57
- }>, "many">;
58
- usage: z.ZodOptional<z.ZodObject<{
59
- prompt_tokens: z.ZodNumber;
60
- completion_tokens: z.ZodNumber;
61
- total_tokens: z.ZodNumber;
62
- }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
63
- prompt_tokens: z.ZodNumber;
64
- completion_tokens: z.ZodNumber;
65
- total_tokens: z.ZodNumber;
66
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
67
- prompt_tokens: z.ZodNumber;
68
- completion_tokens: z.ZodNumber;
69
- total_tokens: z.ZodNumber;
70
- }, z.ZodTypeAny, "passthrough">>>;
71
- citations: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
72
- }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
73
- id: z.ZodString;
74
- model: z.ZodString;
75
- object: z.ZodString;
76
- created: z.ZodNumber;
77
- choices: z.ZodArray<z.ZodObject<{
78
- index: z.ZodNumber;
79
- finish_reason: z.ZodNullable<z.ZodEnum<["stop", "length", "model_length"]>>;
80
- message: z.ZodObject<{
81
- role: z.ZodEnum<["assistant"]>;
82
- content: z.ZodString;
83
- }, "strip", z.ZodTypeAny, {
84
- role: "assistant";
85
- content: string;
86
- }, {
87
- role: "assistant";
88
- content: string;
89
- }>;
90
- delta: z.ZodOptional<z.ZodObject<{
91
- role: z.ZodOptional<z.ZodString>;
92
- content: z.ZodOptional<z.ZodString>;
93
- }, "strip", z.ZodTypeAny, {
94
- role?: string | undefined;
95
- content?: string | undefined;
96
- }, {
97
- role?: string | undefined;
98
- content?: string | undefined;
99
- }>>;
100
- }, "strip", z.ZodTypeAny, {
101
- message: {
102
- role: "assistant";
103
- content: string;
104
- };
105
- index: number;
106
- finish_reason: "length" | "stop" | "model_length" | null;
107
- delta?: {
108
- role?: string | undefined;
109
- content?: string | undefined;
110
- } | undefined;
111
- }, {
112
- message: {
113
- role: "assistant";
114
- content: string;
115
- };
116
- index: number;
117
- finish_reason: "length" | "stop" | "model_length" | null;
118
- delta?: {
119
- role?: string | undefined;
120
- content?: string | undefined;
121
- } | undefined;
122
- }>, "many">;
123
- usage: z.ZodOptional<z.ZodObject<{
124
- prompt_tokens: z.ZodNumber;
125
- completion_tokens: z.ZodNumber;
126
- total_tokens: z.ZodNumber;
127
- }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
128
- prompt_tokens: z.ZodNumber;
129
- completion_tokens: z.ZodNumber;
130
- total_tokens: z.ZodNumber;
131
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
132
- prompt_tokens: z.ZodNumber;
133
- completion_tokens: z.ZodNumber;
134
- total_tokens: z.ZodNumber;
135
- }, z.ZodTypeAny, "passthrough">>>;
136
- citations: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
137
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
138
- id: z.ZodString;
139
- model: z.ZodString;
140
- object: z.ZodString;
141
- created: z.ZodNumber;
142
- choices: z.ZodArray<z.ZodObject<{
143
- index: z.ZodNumber;
144
- finish_reason: z.ZodNullable<z.ZodEnum<["stop", "length", "model_length"]>>;
145
- message: z.ZodObject<{
146
- role: z.ZodEnum<["assistant"]>;
147
- content: z.ZodString;
148
- }, "strip", z.ZodTypeAny, {
149
- role: "assistant";
150
- content: string;
151
- }, {
152
- role: "assistant";
153
- content: string;
154
- }>;
155
- delta: z.ZodOptional<z.ZodObject<{
156
- role: z.ZodOptional<z.ZodString>;
157
- content: z.ZodOptional<z.ZodString>;
158
- }, "strip", z.ZodTypeAny, {
159
- role?: string | undefined;
160
- content?: string | undefined;
161
- }, {
162
- role?: string | undefined;
163
- content?: string | undefined;
164
- }>>;
165
- }, "strip", z.ZodTypeAny, {
166
- message: {
167
- role: "assistant";
168
- content: string;
169
- };
170
- index: number;
171
- finish_reason: "length" | "stop" | "model_length" | null;
172
- delta?: {
173
- role?: string | undefined;
174
- content?: string | undefined;
175
- } | undefined;
176
- }, {
177
- message: {
178
- role: "assistant";
179
- content: string;
180
- };
181
- index: number;
182
- finish_reason: "length" | "stop" | "model_length" | null;
183
- delta?: {
184
- role?: string | undefined;
185
- content?: string | undefined;
186
- } | undefined;
187
- }>, "many">;
188
- usage: z.ZodOptional<z.ZodObject<{
189
- prompt_tokens: z.ZodNumber;
190
- completion_tokens: z.ZodNumber;
191
- total_tokens: z.ZodNumber;
192
- }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
193
- prompt_tokens: z.ZodNumber;
194
- completion_tokens: z.ZodNumber;
195
- total_tokens: z.ZodNumber;
196
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
197
- prompt_tokens: z.ZodNumber;
198
- completion_tokens: z.ZodNumber;
199
- total_tokens: z.ZodNumber;
200
- }, z.ZodTypeAny, "passthrough">>>;
201
- citations: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
202
- }, z.ZodTypeAny, "passthrough">>;
203
- /** Type inferred from the Perplexity response schema */
204
- export type PerplexityResponse = z.infer<typeof perplexityResponseSchema>;
205
- /** Strict validator for Perplexity API responses. Throws on failure. */
206
- export declare const validatePerplexityResponse: (data: unknown) => z.objectInputType<{
207
- id: z.ZodString;
208
- model: z.ZodString;
209
- object: z.ZodString;
210
- created: z.ZodNumber;
211
- choices: z.ZodArray<z.ZodObject<{
212
- index: z.ZodNumber;
213
- finish_reason: z.ZodNullable<z.ZodEnum<["stop", "length", "model_length"]>>;
214
- message: z.ZodObject<{
215
- role: z.ZodEnum<["assistant"]>;
216
- content: z.ZodString;
217
- }, "strip", z.ZodTypeAny, {
218
- role: "assistant";
219
- content: string;
220
- }, {
221
- role: "assistant";
222
- content: string;
223
- }>;
224
- delta: z.ZodOptional<z.ZodObject<{
225
- role: z.ZodOptional<z.ZodString>;
226
- content: z.ZodOptional<z.ZodString>;
227
- }, "strip", z.ZodTypeAny, {
228
- role?: string | undefined;
229
- content?: string | undefined;
230
- }, {
231
- role?: string | undefined;
232
- content?: string | undefined;
233
- }>>;
234
- }, "strip", z.ZodTypeAny, {
235
- message: {
236
- role: "assistant";
237
- content: string;
238
- };
239
- index: number;
240
- finish_reason: "length" | "stop" | "model_length" | null;
241
- delta?: {
242
- role?: string | undefined;
243
- content?: string | undefined;
244
- } | undefined;
245
- }, {
246
- message: {
247
- role: "assistant";
248
- content: string;
249
- };
250
- index: number;
251
- finish_reason: "length" | "stop" | "model_length" | null;
252
- delta?: {
253
- role?: string | undefined;
254
- content?: string | undefined;
255
- } | undefined;
256
- }>, "many">;
257
- usage: z.ZodOptional<z.ZodObject<{
258
- prompt_tokens: z.ZodNumber;
259
- completion_tokens: z.ZodNumber;
260
- total_tokens: z.ZodNumber;
261
- }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
262
- prompt_tokens: z.ZodNumber;
263
- completion_tokens: z.ZodNumber;
264
- total_tokens: z.ZodNumber;
265
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
266
- prompt_tokens: z.ZodNumber;
267
- completion_tokens: z.ZodNumber;
268
- total_tokens: z.ZodNumber;
269
- }, z.ZodTypeAny, "passthrough">>>;
270
- citations: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
271
- }, z.ZodTypeAny, "passthrough">;
272
- /** Safe validator for Perplexity API responses. Never throws. */
273
- export declare const safeValidatePerplexityResponse: (data: unknown) => import("./validation-helpers").ValidationResult<z.objectInputType<{
274
- id: z.ZodString;
275
- model: z.ZodString;
276
- object: z.ZodString;
277
- created: z.ZodNumber;
278
- choices: z.ZodArray<z.ZodObject<{
279
- index: z.ZodNumber;
280
- finish_reason: z.ZodNullable<z.ZodEnum<["stop", "length", "model_length"]>>;
281
- message: z.ZodObject<{
282
- role: z.ZodEnum<["assistant"]>;
283
- content: z.ZodString;
284
- }, "strip", z.ZodTypeAny, {
285
- role: "assistant";
286
- content: string;
287
- }, {
288
- role: "assistant";
289
- content: string;
290
- }>;
291
- delta: z.ZodOptional<z.ZodObject<{
292
- role: z.ZodOptional<z.ZodString>;
293
- content: z.ZodOptional<z.ZodString>;
294
- }, "strip", z.ZodTypeAny, {
295
- role?: string | undefined;
296
- content?: string | undefined;
297
- }, {
298
- role?: string | undefined;
299
- content?: string | undefined;
300
- }>>;
301
- }, "strip", z.ZodTypeAny, {
302
- message: {
303
- role: "assistant";
304
- content: string;
305
- };
306
- index: number;
307
- finish_reason: "length" | "stop" | "model_length" | null;
308
- delta?: {
309
- role?: string | undefined;
310
- content?: string | undefined;
311
- } | undefined;
312
- }, {
313
- message: {
314
- role: "assistant";
315
- content: string;
316
- };
317
- index: number;
318
- finish_reason: "length" | "stop" | "model_length" | null;
319
- delta?: {
320
- role?: string | undefined;
321
- content?: string | undefined;
322
- } | undefined;
323
- }>, "many">;
324
- usage: z.ZodOptional<z.ZodObject<{
325
- prompt_tokens: z.ZodNumber;
326
- completion_tokens: z.ZodNumber;
327
- total_tokens: z.ZodNumber;
328
- }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
329
- prompt_tokens: z.ZodNumber;
330
- completion_tokens: z.ZodNumber;
331
- total_tokens: z.ZodNumber;
332
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
333
- prompt_tokens: z.ZodNumber;
334
- completion_tokens: z.ZodNumber;
335
- total_tokens: z.ZodNumber;
336
- }, z.ZodTypeAny, "passthrough">>>;
337
- citations: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
338
- }, z.ZodTypeAny, "passthrough">>;
@@ -1,33 +0,0 @@
1
- import { z } from 'zod';
2
- /**
3
- * Result of a safe validation attempt.
4
- * On success, contains the parsed data. On failure, contains the error details.
5
- */
6
- export interface ValidationResult<T> {
7
- success: boolean;
8
- data?: T;
9
- error?: string;
10
- issues?: Array<{
11
- path: string;
12
- message: string;
13
- }>;
14
- }
15
- /**
16
- * Creates a strict validator function for a Zod schema.
17
- * Throws on validation failure with a descriptive error message.
18
- *
19
- * @param schema - The Zod schema to validate against
20
- * @param serviceName - Human-readable service name for error messages
21
- * @returns A validator function that parses and returns typed data
22
- */
23
- export declare function createValidator<T>(schema: z.ZodType<T>, serviceName: string): (data: unknown) => T;
24
- /**
25
- * Creates a safe validator function for a Zod schema.
26
- * Never throws; returns a ValidationResult with success/failure information.
27
- * On failure, logs a warning but does not throw.
28
- *
29
- * @param schema - The Zod schema to validate against
30
- * @param serviceName - Human-readable service name for log messages
31
- * @returns A safe validator function that returns a ValidationResult
32
- */
33
- export declare function createSafeValidator<T>(schema: z.ZodType<T>, serviceName: string): (data: unknown) => ValidationResult<T>;
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,99 +0,0 @@
1
- /**
2
- * Possible states for a circuit breaker
3
- */
4
- export declare enum CircuitBreakerState {
5
- CLOSED = "CLOSED",
6
- OPEN = "OPEN",
7
- HALF_OPEN = "HALF_OPEN"
8
- }
9
- /**
10
- * Configuration for the circuit breaker
11
- */
12
- export interface CircuitBreakerConfig {
13
- /** Number of failures before the circuit opens (default: 5) */
14
- failureThreshold: number;
15
- /** Time in milliseconds before attempting recovery from OPEN state (default: 30000) */
16
- resetTimeoutMs: number;
17
- /** Number of consecutive successes in HALF_OPEN required to close the circuit (default: 3) */
18
- successThreshold: number;
19
- }
20
- /**
21
- * Callback invoked when the circuit breaker changes state
22
- */
23
- export type CircuitBreakerStateChangeCallback = (from: CircuitBreakerState, to: CircuitBreakerState, serviceName: string) => void;
24
- /**
25
- * Default circuit breaker configuration
26
- */
27
- export declare const DEFAULT_CIRCUIT_BREAKER_CONFIG: CircuitBreakerConfig;
28
- /**
29
- * Error thrown when a circuit breaker is open and rejecting calls
30
- */
31
- export declare class CircuitBreakerOpenError extends Error {
32
- readonly serviceName: string;
33
- readonly resetTimeoutMs: number;
34
- constructor(serviceName: string, resetTimeoutMs: number);
35
- }
36
- /**
37
- * Generic circuit breaker implementation for external service calls.
38
- *
39
- * The circuit breaker monitors failures and transitions through three states:
40
- * - CLOSED: Normal operation. Calls pass through. Failures are counted.
41
- * - OPEN: Too many failures. Calls are rejected immediately without executing.
42
- * - HALF_OPEN: After a reset timeout, allows a limited number of trial calls
43
- * to test whether the service has recovered.
44
- *
45
- * @example
46
- * const breaker = new CircuitBreaker('slack-api');
47
- * const result = await breaker.execute(() => sendSlackMessage(channel, msg));
48
- */
49
- export declare class CircuitBreaker {
50
- readonly serviceName: string;
51
- private state;
52
- private failureCount;
53
- private successCount;
54
- private lastFailureTime;
55
- private readonly config;
56
- private onStateChange;
57
- constructor(serviceName: string, config?: Partial<CircuitBreakerConfig>, onStateChange?: CircuitBreakerStateChangeCallback);
58
- /**
59
- * Returns the current state of the circuit breaker.
60
- */
61
- getState(): CircuitBreakerState;
62
- /**
63
- * Returns the current failure count.
64
- */
65
- getFailureCount(): number;
66
- /**
67
- * Returns the current success count (relevant in HALF_OPEN state).
68
- */
69
- getSuccessCount(): number;
70
- /**
71
- * Resets the circuit breaker to its initial CLOSED state.
72
- */
73
- reset(): void;
74
- /**
75
- * Executes the provided function through the circuit breaker.
76
- *
77
- * - In CLOSED state: executes normally, tracking failures.
78
- * - In OPEN state: rejects immediately with CircuitBreakerOpenError
79
- * unless the reset timeout has elapsed, in which case it transitions to HALF_OPEN.
80
- * - In HALF_OPEN state: allows trial calls, tracking successes to decide
81
- * whether to close or re-open the circuit.
82
- *
83
- * @template T - The return type of the wrapped function
84
- * @param fn - The async function to execute
85
- * @returns The result of the function call
86
- * @throws CircuitBreakerOpenError if the circuit is open
87
- * @throws The original error if the function call fails
88
- */
89
- execute<T>(fn: () => Promise<T>): Promise<T>;
90
- /**
91
- * Sets or replaces the state change callback.
92
- */
93
- setOnStateChange(callback: CircuitBreakerStateChangeCallback): void;
94
- private shouldAttemptReset;
95
- private onSuccess;
96
- private onFailure;
97
- private transitionTo;
98
- private notifyStateChange;
99
- }
@@ -1,43 +0,0 @@
1
- /**
2
- * Correlation context stored in AsyncLocalStorage.
3
- * Propagates automatically through async call chains.
4
- */
5
- export interface CorrelationContext {
6
- /** Unique correlation ID for request tracing */
7
- correlationId: string;
8
- /** Additional metadata to propagate */
9
- metadata?: Record<string, string>;
10
- }
11
- /**
12
- * Generates a new unique correlation ID.
13
- * Uses crypto.randomUUID for high-quality UUIDs.
14
- * @returns A new UUID string
15
- */
16
- export declare function generateCorrelationId(): string;
17
- /**
18
- * Returns the current correlation ID from AsyncLocalStorage, or undefined if none is set.
19
- * @returns The current correlation ID or undefined
20
- */
21
- export declare function getCorrelationId(): string | undefined;
22
- /**
23
- * Returns the full correlation context, or undefined if none is set.
24
- * @returns The current CorrelationContext or undefined
25
- */
26
- export declare function getCorrelationContext(): CorrelationContext | undefined;
27
- /**
28
- * Runs a function within a correlation context.
29
- * All async operations within the callback will have access to the correlation ID.
30
- *
31
- * @param fn - The function to run within the context
32
- * @param correlationId - Optional correlation ID. If not provided, one is generated.
33
- * @param metadata - Optional metadata to attach to the context
34
- * @returns The return value of the function
35
- */
36
- export declare function withCorrelationId<T>(fn: () => T, correlationId?: string, metadata?: Record<string, string>): T;
37
- /**
38
- * Returns headers object with the correlation ID for external HTTP calls.
39
- * Returns an empty object if no correlation context is active.
40
- * @param headerName - The header name to use (default: 'x-correlation-id')
41
- * @returns Headers object with correlation ID
42
- */
43
- export declare function getCorrelationHeaders(headerName?: string): Record<string, string>;
@@ -1,50 +0,0 @@
1
- /**
2
- * Status of an individual integration health check.
3
- */
4
- export interface IntegrationHealthStatus {
5
- /** Name of the integration being checked */
6
- service: string;
7
- /** Whether the integration is reachable */
8
- healthy: boolean;
9
- /** Human-readable status message */
10
- message: string;
11
- /** Time taken to check in milliseconds */
12
- latencyMs: number;
13
- /** Error details if unhealthy */
14
- error?: string;
15
- }
16
- /**
17
- * Overall health check result for all configured integrations.
18
- */
19
- export interface HealthCheckResult {
20
- /** Whether all checked integrations are healthy */
21
- healthy: boolean;
22
- /** Timestamp of the health check */
23
- timestamp: string;
24
- /** Individual integration statuses */
25
- integrations: IntegrationHealthStatus[];
26
- /** Total time taken for all checks in milliseconds */
27
- totalLatencyMs: number;
28
- }
29
- /**
30
- * Runs health checks for all configured integrations.
31
- *
32
- * Checks credential configuration for each external service. Does not make
33
- * actual API calls (to avoid side effects and rate limit consumption).
34
- * For connectivity verification, consumers should use the individual service
35
- * functions with appropriate error handling.
36
- *
37
- * @param services - Optional list of service names to check. If omitted, checks all.
38
- * @returns Health check result with individual integration statuses
39
- *
40
- * @example
41
- * const result = await checkIntegrationHealth();
42
- * if (!result.healthy) {
43
- * console.error('Unhealthy integrations:', result.integrations.filter(i => !i.healthy));
44
- * }
45
- *
46
- * @example
47
- * // Check specific services only
48
- * const result = await checkIntegrationHealth(['openai', 'slack']);
49
- */
50
- export declare function checkIntegrationHealth(services?: string[]): Promise<HealthCheckResult>;
@@ -1,51 +0,0 @@
1
- /**
2
- * Input validation utilities to prevent injection and traversal attacks
3
- * on external service inputs (Slack, S3, Google Sheets).
4
- */
5
- /**
6
- * Result of a validation check
7
- */
8
- export interface ValidationResult {
9
- valid: boolean;
10
- error?: string;
11
- }
12
- /**
13
- * Validates a Slack channel name format.
14
- *
15
- * Valid channel names:
16
- * - May optionally start with '#'
17
- * - Must start with a lowercase letter or number (after optional '#')
18
- * - May contain lowercase letters, numbers, hyphens, and underscores
19
- * - Must be between 1 and 80 characters (excluding optional '#' prefix)
20
- *
21
- * @param channel - The channel name to validate
22
- * @returns ValidationResult indicating whether the channel name is valid
23
- */
24
- export declare function validateSlackChannel(channel: string): ValidationResult;
25
- /**
26
- * Validates an S3 key to prevent directory traversal and other attacks.
27
- *
28
- * Invalid keys:
29
- * - Contain '..' (directory traversal)
30
- * - Start with '/' (absolute paths)
31
- * - Contain null bytes
32
- * - Are empty
33
- * - Exceed 1024 characters (S3 key limit)
34
- *
35
- * @param key - The S3 key to validate
36
- * @returns ValidationResult indicating whether the key is valid
37
- */
38
- export declare function validateS3Key(key: string): ValidationResult;
39
- /**
40
- * Validates a Google Sheets A1 notation range.
41
- *
42
- * Valid formats:
43
- * - Simple cell: 'A1', 'B2', 'AA100'
44
- * - Cell range: 'A1:B10', 'A1:Z999'
45
- * - With sheet name: 'Sheet1!A1', 'Sheet1!A1:B10'
46
- * - With quoted sheet name: "'My Sheet'!A1:B10"
47
- *
48
- * @param range - The A1 notation string to validate
49
- * @returns ValidationResult indicating whether the range is valid
50
- */
51
- export declare function validateGoogleSheetsRange(range: string): ValidationResult;