@adaptic/lumic-utils 1.0.11 → 1.0.13

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 (91) hide show
  1. package/dist/apollo-client.client-BXL45tI8.js +3704 -0
  2. package/dist/apollo-client.client-BXL45tI8.js.map +1 -0
  3. package/dist/apollo-client.client-DU-axkDV.js +3693 -0
  4. package/dist/apollo-client.client-DU-axkDV.js.map +1 -0
  5. package/dist/apollo-client.server-CsF1Ouw2.js +16319 -0
  6. package/dist/apollo-client.server-CsF1Ouw2.js.map +1 -0
  7. package/dist/apollo-client.server-DsMOuLeH.js +16321 -0
  8. package/dist/apollo-client.server-DsMOuLeH.js.map +1 -0
  9. package/dist/index-C01wYFKR.js +81388 -0
  10. package/dist/index-C01wYFKR.js.map +1 -0
  11. package/dist/index-ChYbCXnO.js +12271 -0
  12. package/dist/index-ChYbCXnO.js.map +1 -0
  13. package/dist/{index-CcXQeJz8.js → index-Cstek604.js} +182 -22
  14. package/dist/index-Cstek604.js.map +1 -0
  15. package/dist/{index-CcgbRft2.js → index-DZZCd-1T.js} +182 -22
  16. package/dist/index-DZZCd-1T.js.map +1 -0
  17. package/dist/index-FzTQZ3fX.js +81181 -0
  18. package/dist/index-FzTQZ3fX.js.map +1 -0
  19. package/dist/index-hlhvI_Sn.js +12108 -0
  20. package/dist/index-hlhvI_Sn.js.map +1 -0
  21. package/dist/index.cjs +136 -11417
  22. package/dist/index.cjs.map +1 -1
  23. package/dist/index.mjs +39 -11399
  24. package/dist/index.mjs.map +1 -1
  25. package/dist/test.cjs +24 -7
  26. package/dist/test.cjs.map +1 -1
  27. package/dist/test.mjs +24 -7
  28. package/dist/test.mjs.map +1 -1
  29. package/dist/types/config/__tests__/secrets.test.d.ts +1 -0
  30. package/dist/types/config/secrets.d.ts +286 -0
  31. package/dist/types/errors/__tests__/errors.test.d.ts +1 -0
  32. package/dist/types/errors/index.d.ts +77 -0
  33. package/dist/types/functions/__tests__/aws-lambda.test.d.ts +1 -0
  34. package/dist/types/functions/__tests__/aws-s3-utils.test.d.ts +1 -0
  35. package/dist/types/functions/__tests__/json-llm-tools.test.d.ts +1 -0
  36. package/dist/types/functions/__tests__/json-tools.test.d.ts +1 -0
  37. package/dist/types/functions/__tests__/slack-utils.test.d.ts +1 -0
  38. package/dist/types/functions/aws-lambda.d.ts +1 -1
  39. package/dist/types/functions/aws-s3-utils.d.ts +2 -2
  40. package/dist/types/functions/google-sheets.d.ts +4 -4
  41. package/dist/types/functions/json-llm-tools.d.ts +25 -3
  42. package/dist/types/functions/llm-anthropic.d.ts +14 -0
  43. package/dist/types/functions/llm-call.d.ts +14 -3
  44. package/dist/types/functions/llm-config.d.ts +13 -8
  45. package/dist/types/functions/llm-deepseek.d.ts +1 -1
  46. package/dist/types/functions/llm-openai-compatible.d.ts +15 -0
  47. package/dist/types/functions/llm-openai.d.ts +3 -2
  48. package/dist/types/functions/llm-utils.d.ts +24 -1
  49. package/dist/types/functions/slack-utils.d.ts +3 -4
  50. package/dist/types/functions/utils.d.ts +2 -14
  51. package/dist/types/functions/zip-utils.d.ts +12 -10
  52. package/dist/types/index.d.ts +33 -0
  53. package/dist/types/schemas/aws-schemas.d.ts +210 -0
  54. package/dist/types/schemas/google-sheets-schemas.d.ts +32 -0
  55. package/dist/types/schemas/index.d.ts +17 -0
  56. package/dist/types/schemas/openai-schemas.d.ts +834 -0
  57. package/dist/types/schemas/perplexity-schemas.d.ts +338 -0
  58. package/dist/types/schemas/validation-helpers.d.ts +33 -0
  59. package/dist/types/types/aws-types.d.ts +1 -1
  60. package/dist/types/types/google-types.d.ts +5 -3
  61. package/dist/types/types/index.d.ts +1 -1
  62. package/dist/types/types/openai-types.d.ts +396 -6
  63. package/dist/types/utils/__tests__/circuit-breaker.test.d.ts +1 -0
  64. package/dist/types/utils/__tests__/correlation.test.d.ts +1 -0
  65. package/dist/types/utils/__tests__/input-validator.test.d.ts +1 -0
  66. package/dist/types/utils/__tests__/llm-cost-tracker.test.d.ts +1 -0
  67. package/dist/types/utils/__tests__/logger.test.d.ts +1 -0
  68. package/dist/types/utils/__tests__/metrics.test.d.ts +1 -0
  69. package/dist/types/utils/__tests__/retry.test.d.ts +1 -0
  70. package/dist/types/utils/__tests__/sanitizer.test.d.ts +1 -0
  71. package/dist/types/utils/__tests__/timeouts.test.d.ts +1 -0
  72. package/dist/types/utils/aws-initialise.d.ts +6 -1
  73. package/dist/types/utils/circuit-breaker.d.ts +99 -0
  74. package/dist/types/utils/config.d.ts +40 -2
  75. package/dist/types/utils/correlation.d.ts +43 -0
  76. package/dist/types/utils/health-check.d.ts +50 -0
  77. package/dist/types/utils/input-validator.d.ts +51 -0
  78. package/dist/types/utils/llm-cost-tracker.d.ts +174 -0
  79. package/dist/types/utils/logger.d.ts +8 -0
  80. package/dist/types/utils/metrics.d.ts +61 -0
  81. package/dist/types/utils/rate-limiter.d.ts +85 -0
  82. package/dist/types/utils/retry.d.ts +58 -0
  83. package/dist/types/utils/sanitizer.d.ts +30 -0
  84. package/dist/types/utils/timeouts.d.ts +44 -0
  85. package/package.json +3 -2
  86. package/dist/index-CcXQeJz8.js.map +0 -1
  87. package/dist/index-CcgbRft2.js.map +0 -1
  88. package/dist/types/aws-types.ts +0 -64
  89. package/dist/types/google-types.ts +0 -48
  90. package/dist/types/index.ts +0 -57
  91. package/dist/types/openai-types.ts +0 -92
@@ -0,0 +1,338 @@
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
+ content: string;
20
+ role: "assistant";
21
+ }, {
22
+ content: string;
23
+ role: "assistant";
24
+ }>;
25
+ delta: z.ZodOptional<z.ZodObject<{
26
+ role: z.ZodOptional<z.ZodString>;
27
+ content: z.ZodOptional<z.ZodString>;
28
+ }, "strip", z.ZodTypeAny, {
29
+ content?: string | undefined;
30
+ role?: string | undefined;
31
+ }, {
32
+ content?: string | undefined;
33
+ role?: string | undefined;
34
+ }>>;
35
+ }, "strip", z.ZodTypeAny, {
36
+ message: {
37
+ content: string;
38
+ role: "assistant";
39
+ };
40
+ index: number;
41
+ finish_reason: "length" | "stop" | "model_length" | null;
42
+ delta?: {
43
+ content?: string | undefined;
44
+ role?: string | undefined;
45
+ } | undefined;
46
+ }, {
47
+ message: {
48
+ content: string;
49
+ role: "assistant";
50
+ };
51
+ index: number;
52
+ finish_reason: "length" | "stop" | "model_length" | null;
53
+ delta?: {
54
+ content?: string | undefined;
55
+ role?: 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
+ content: string;
85
+ role: "assistant";
86
+ }, {
87
+ content: string;
88
+ role: "assistant";
89
+ }>;
90
+ delta: z.ZodOptional<z.ZodObject<{
91
+ role: z.ZodOptional<z.ZodString>;
92
+ content: z.ZodOptional<z.ZodString>;
93
+ }, "strip", z.ZodTypeAny, {
94
+ content?: string | undefined;
95
+ role?: string | undefined;
96
+ }, {
97
+ content?: string | undefined;
98
+ role?: string | undefined;
99
+ }>>;
100
+ }, "strip", z.ZodTypeAny, {
101
+ message: {
102
+ content: string;
103
+ role: "assistant";
104
+ };
105
+ index: number;
106
+ finish_reason: "length" | "stop" | "model_length" | null;
107
+ delta?: {
108
+ content?: string | undefined;
109
+ role?: string | undefined;
110
+ } | undefined;
111
+ }, {
112
+ message: {
113
+ content: string;
114
+ role: "assistant";
115
+ };
116
+ index: number;
117
+ finish_reason: "length" | "stop" | "model_length" | null;
118
+ delta?: {
119
+ content?: string | undefined;
120
+ role?: 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
+ content: string;
150
+ role: "assistant";
151
+ }, {
152
+ content: string;
153
+ role: "assistant";
154
+ }>;
155
+ delta: z.ZodOptional<z.ZodObject<{
156
+ role: z.ZodOptional<z.ZodString>;
157
+ content: z.ZodOptional<z.ZodString>;
158
+ }, "strip", z.ZodTypeAny, {
159
+ content?: string | undefined;
160
+ role?: string | undefined;
161
+ }, {
162
+ content?: string | undefined;
163
+ role?: string | undefined;
164
+ }>>;
165
+ }, "strip", z.ZodTypeAny, {
166
+ message: {
167
+ content: string;
168
+ role: "assistant";
169
+ };
170
+ index: number;
171
+ finish_reason: "length" | "stop" | "model_length" | null;
172
+ delta?: {
173
+ content?: string | undefined;
174
+ role?: string | undefined;
175
+ } | undefined;
176
+ }, {
177
+ message: {
178
+ content: string;
179
+ role: "assistant";
180
+ };
181
+ index: number;
182
+ finish_reason: "length" | "stop" | "model_length" | null;
183
+ delta?: {
184
+ content?: string | undefined;
185
+ role?: 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
+ content: string;
219
+ role: "assistant";
220
+ }, {
221
+ content: string;
222
+ role: "assistant";
223
+ }>;
224
+ delta: z.ZodOptional<z.ZodObject<{
225
+ role: z.ZodOptional<z.ZodString>;
226
+ content: z.ZodOptional<z.ZodString>;
227
+ }, "strip", z.ZodTypeAny, {
228
+ content?: string | undefined;
229
+ role?: string | undefined;
230
+ }, {
231
+ content?: string | undefined;
232
+ role?: string | undefined;
233
+ }>>;
234
+ }, "strip", z.ZodTypeAny, {
235
+ message: {
236
+ content: string;
237
+ role: "assistant";
238
+ };
239
+ index: number;
240
+ finish_reason: "length" | "stop" | "model_length" | null;
241
+ delta?: {
242
+ content?: string | undefined;
243
+ role?: string | undefined;
244
+ } | undefined;
245
+ }, {
246
+ message: {
247
+ content: string;
248
+ role: "assistant";
249
+ };
250
+ index: number;
251
+ finish_reason: "length" | "stop" | "model_length" | null;
252
+ delta?: {
253
+ content?: string | undefined;
254
+ role?: 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
+ content: string;
286
+ role: "assistant";
287
+ }, {
288
+ content: string;
289
+ role: "assistant";
290
+ }>;
291
+ delta: z.ZodOptional<z.ZodObject<{
292
+ role: z.ZodOptional<z.ZodString>;
293
+ content: z.ZodOptional<z.ZodString>;
294
+ }, "strip", z.ZodTypeAny, {
295
+ content?: string | undefined;
296
+ role?: string | undefined;
297
+ }, {
298
+ content?: string | undefined;
299
+ role?: string | undefined;
300
+ }>>;
301
+ }, "strip", z.ZodTypeAny, {
302
+ message: {
303
+ content: string;
304
+ role: "assistant";
305
+ };
306
+ index: number;
307
+ finish_reason: "length" | "stop" | "model_length" | null;
308
+ delta?: {
309
+ content?: string | undefined;
310
+ role?: string | undefined;
311
+ } | undefined;
312
+ }, {
313
+ message: {
314
+ content: string;
315
+ role: "assistant";
316
+ };
317
+ index: number;
318
+ finish_reason: "length" | "stop" | "model_length" | null;
319
+ delta?: {
320
+ content?: string | undefined;
321
+ role?: 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">>;
@@ -0,0 +1,33 @@
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>;
@@ -29,7 +29,7 @@ export interface SaveToS3Response {
29
29
  }
30
30
  export interface LoadFromS3Response {
31
31
  success: boolean;
32
- content?: any;
32
+ content?: unknown;
33
33
  error?: string;
34
34
  }
35
35
  export interface CheckBucketResponse {
@@ -10,15 +10,17 @@ export interface GoogleSheetRange {
10
10
  startCell: GoogleSheetCell;
11
11
  endCell: GoogleSheetCell;
12
12
  }
13
+ /** Represents a primitive value that can be stored in a Google Sheet cell */
14
+ export type GoogleSheetCellValue = string | number | boolean | null;
13
15
  export interface GoogleSheetResponse {
14
16
  success: boolean;
15
17
  error?: string;
16
- data?: any;
18
+ data?: unknown;
17
19
  }
18
20
  export interface GoogleSheetAddRowResponse extends GoogleSheetResponse {
19
21
  data?: {
20
22
  rowNumber: number;
21
- values: any[];
23
+ values: GoogleSheetCellValue[];
22
24
  };
23
25
  }
24
26
  export interface GoogleSheetAddSheetResponse extends GoogleSheetResponse {
@@ -29,7 +31,7 @@ export interface GoogleSheetAddSheetResponse extends GoogleSheetResponse {
29
31
  }
30
32
  export interface GoogleSheetCellResponse extends GoogleSheetResponse {
31
33
  data?: {
32
- value: any;
34
+ value: GoogleSheetCellValue;
33
35
  };
34
36
  }
35
37
  export interface GoogleSheetWriteArrayResponse extends GoogleSheetResponse {
@@ -20,7 +20,7 @@ export interface PerplexityResponse {
20
20
  export type InvocationType = 'RequestResponse' | 'Event' | 'DryRun';
21
21
  export interface LambdaResponse {
22
22
  statusCode: number;
23
- [key: string]: any;
23
+ [key: string]: unknown;
24
24
  }
25
25
  export interface SlackApiResponse {
26
26
  ok: boolean;