polarity-integration-utils 2.0.8 → 3.1.3

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 (139) hide show
  1. package/dist/dts/context/cache.d.ts +149 -0
  2. package/dist/dts/context/cache.d.ts.map +1 -0
  3. package/dist/dts/context/index.d.ts +3 -0
  4. package/dist/dts/context/index.d.ts.map +1 -0
  5. package/dist/dts/context/integration-context.d.ts +16 -0
  6. package/dist/dts/context/integration-context.d.ts.map +1 -0
  7. package/dist/dts/index.d.ts +4 -1
  8. package/dist/dts/index.d.ts.map +1 -1
  9. package/dist/dts/index.docs.d.ts +1 -0
  10. package/dist/dts/index.docs.d.ts.map +1 -1
  11. package/dist/dts/lib/context/cache.d.ts +149 -0
  12. package/dist/dts/lib/context/cache.d.ts.map +1 -0
  13. package/dist/dts/lib/context/index.d.ts +3 -0
  14. package/dist/dts/lib/context/index.d.ts.map +1 -0
  15. package/dist/dts/lib/context/integration-context.d.ts +16 -0
  16. package/dist/dts/lib/context/integration-context.d.ts.map +1 -0
  17. package/dist/dts/lib/errors/api-request-error.d.ts +10 -0
  18. package/dist/dts/lib/errors/api-request-error.d.ts.map +1 -0
  19. package/dist/dts/lib/errors/auth-request-error.d.ts +10 -0
  20. package/dist/dts/lib/errors/auth-request-error.d.ts.map +1 -0
  21. package/dist/dts/lib/errors/index.d.ts +8 -0
  22. package/dist/dts/lib/errors/index.d.ts.map +1 -0
  23. package/dist/dts/lib/errors/integration-error.d.ts +189 -0
  24. package/dist/dts/lib/errors/integration-error.d.ts.map +1 -0
  25. package/dist/dts/lib/errors/library-usage-error.d.ts +12 -0
  26. package/dist/dts/lib/errors/library-usage-error.d.ts.map +1 -0
  27. package/dist/dts/lib/errors/network-error.d.ts +11 -0
  28. package/dist/dts/lib/errors/network-error.d.ts.map +1 -0
  29. package/dist/dts/lib/errors/parse-error-to-readable-json.d.ts +7 -0
  30. package/dist/dts/lib/errors/parse-error-to-readable-json.d.ts.map +1 -0
  31. package/dist/dts/lib/errors/retry-request-error.d.ts +11 -0
  32. package/dist/dts/lib/errors/retry-request-error.d.ts.map +1 -0
  33. package/dist/dts/lib/index.d.ts +8 -0
  34. package/dist/dts/lib/index.d.ts.map +1 -0
  35. package/dist/dts/lib/index.docs.d.ts +10 -0
  36. package/dist/dts/lib/index.docs.d.ts.map +1 -0
  37. package/dist/dts/lib/internal/helpers/parallel-limit.d.ts +9 -0
  38. package/dist/dts/lib/internal/helpers/parallel-limit.d.ts.map +1 -0
  39. package/dist/dts/lib/internal/helpers/sanitize-object.d.ts +11 -0
  40. package/dist/dts/lib/internal/helpers/sanitize-object.d.ts.map +1 -0
  41. package/dist/dts/lib/logging/index.d.ts +2 -0
  42. package/dist/dts/lib/logging/index.d.ts.map +1 -0
  43. package/dist/dts/lib/logging/logger.d.ts +49 -0
  44. package/dist/dts/lib/logging/logger.d.ts.map +1 -0
  45. package/dist/dts/lib/requests/index.d.ts +3 -0
  46. package/dist/dts/lib/requests/index.d.ts.map +1 -0
  47. package/dist/dts/lib/requests/polarity-request.d.ts +411 -0
  48. package/dist/dts/lib/requests/polarity-request.d.ts.map +1 -0
  49. package/dist/dts/lib/requests/sanitize-request-options.d.ts +20 -0
  50. package/dist/dts/lib/requests/sanitize-request-options.d.ts.map +1 -0
  51. package/dist/dts/lib/testing/enhanced-utils/create-entity.d.ts +3 -0
  52. package/dist/dts/lib/testing/enhanced-utils/create-entity.d.ts.map +1 -0
  53. package/dist/dts/lib/testing/enhanced-utils/create-mock-integration-context.d.ts +3 -0
  54. package/dist/dts/lib/testing/enhanced-utils/create-mock-integration-context.d.ts.map +1 -0
  55. package/dist/dts/lib/testing/enhanced-utils/mock-request.d.ts +14 -0
  56. package/dist/dts/lib/testing/enhanced-utils/mock-request.d.ts.map +1 -0
  57. package/dist/dts/lib/testing/enhanced-utils/validate-integration.d.ts +8 -0
  58. package/dist/dts/lib/testing/enhanced-utils/validate-integration.d.ts.map +1 -0
  59. package/dist/dts/lib/testing/index.d.ts +6 -0
  60. package/dist/dts/lib/testing/index.d.ts.map +1 -0
  61. package/dist/dts/lib/testing/test-factory/create-integration-tests.d.ts +6 -0
  62. package/dist/dts/lib/testing/test-factory/create-integration-tests.d.ts.map +1 -0
  63. package/dist/dts/lib/testing/test-factory/test-do-lookup.d.ts +7 -0
  64. package/dist/dts/lib/testing/test-factory/test-do-lookup.d.ts.map +1 -0
  65. package/dist/dts/lib/testing/test-factory/test-on-message.d.ts +8 -0
  66. package/dist/dts/lib/testing/test-factory/test-on-message.d.ts.map +1 -0
  67. package/dist/dts/lib/types.d.ts +101 -0
  68. package/dist/dts/lib/types.d.ts.map +1 -0
  69. package/dist/dts/lib/zod-types.d.ts +278 -0
  70. package/dist/dts/lib/zod-types.d.ts.map +1 -0
  71. package/dist/dts/testing/enhanced-utils/create-entity.d.ts +3 -0
  72. package/dist/dts/testing/enhanced-utils/create-entity.d.ts.map +1 -0
  73. package/dist/dts/testing/enhanced-utils/create-mock-integration-context.d.ts +3 -0
  74. package/dist/dts/testing/enhanced-utils/create-mock-integration-context.d.ts.map +1 -0
  75. package/dist/dts/testing/enhanced-utils/mock-request.d.ts +14 -0
  76. package/dist/dts/testing/enhanced-utils/mock-request.d.ts.map +1 -0
  77. package/dist/dts/testing/enhanced-utils/validate-integration.d.ts +8 -0
  78. package/dist/dts/testing/enhanced-utils/validate-integration.d.ts.map +1 -0
  79. package/dist/dts/testing/index.d.ts +6 -0
  80. package/dist/dts/testing/index.d.ts.map +1 -0
  81. package/dist/dts/testing/test-factory/create-integration-tests.d.ts +6 -0
  82. package/dist/dts/testing/test-factory/create-integration-tests.d.ts.map +1 -0
  83. package/dist/dts/testing/test-factory/test-do-lookup.d.ts +7 -0
  84. package/dist/dts/testing/test-factory/test-do-lookup.d.ts.map +1 -0
  85. package/dist/dts/testing/test-factory/test-on-message.d.ts +8 -0
  86. package/dist/dts/testing/test-factory/test-on-message.d.ts.map +1 -0
  87. package/dist/{tsdoc-metadata.json → dts/tsdoc-metadata.json} +1 -1
  88. package/dist/dts/types.d.ts +50 -53
  89. package/dist/dts/types.d.ts.map +1 -1
  90. package/dist/dts/zod-types.d.ts +278 -0
  91. package/dist/dts/zod-types.d.ts.map +1 -0
  92. package/dist/es/lib/context/index.js +18 -0
  93. package/dist/es/lib/context/integration-context.js +2 -0
  94. package/dist/es/{errors → lib/errors}/network-error.js +1 -1
  95. package/dist/es/{index.docs.js → lib/index.docs.js} +1 -0
  96. package/dist/es/{index.js → lib/index.js} +9 -1
  97. package/dist/es/lib/testing/enhanced-utils/create-entity.js +37 -0
  98. package/dist/es/lib/testing/enhanced-utils/create-mock-integration-context.js +36 -0
  99. package/dist/es/lib/testing/enhanced-utils/mock-request.js +22 -0
  100. package/dist/es/lib/testing/enhanced-utils/validate-integration.js +159 -0
  101. package/dist/es/lib/testing/index.js +21 -0
  102. package/dist/es/lib/testing/test-factory/create-integration-tests.js +53 -0
  103. package/dist/es/lib/testing/test-factory/test-do-lookup.js +24 -0
  104. package/dist/es/lib/testing/test-factory/test-on-message.js +24 -0
  105. package/dist/es/lib/types.js +5 -0
  106. package/dist/es/lib/zod-types.js +206 -0
  107. package/dist/lib/context/cache.js +2 -0
  108. package/dist/lib/context/index.js +18 -0
  109. package/dist/lib/context/integration-context.js +2 -0
  110. package/dist/lib/errors/network-error.js +1 -1
  111. package/dist/lib/index.docs.js +1 -0
  112. package/dist/lib/index.js +9 -1
  113. package/dist/lib/testing/enhanced-utils/create-entity.js +37 -0
  114. package/dist/lib/testing/enhanced-utils/create-mock-integration-context.js +36 -0
  115. package/dist/lib/testing/enhanced-utils/mock-request.js +22 -0
  116. package/dist/lib/testing/enhanced-utils/validate-integration.js +159 -0
  117. package/dist/lib/testing/index.js +21 -0
  118. package/dist/lib/testing/test-factory/create-integration-tests.js +53 -0
  119. package/dist/lib/testing/test-factory/test-do-lookup.js +24 -0
  120. package/dist/lib/testing/test-factory/test-on-message.js +24 -0
  121. package/dist/lib/types.js +3 -0
  122. package/dist/lib/zod-types.js +206 -0
  123. package/dist/polarity-integration-utils.d.ts +461 -54
  124. package/package.json +30 -9
  125. /package/dist/es/{types.js → lib/context/cache.js} +0 -0
  126. /package/dist/es/{errors → lib/errors}/api-request-error.js +0 -0
  127. /package/dist/es/{errors → lib/errors}/auth-request-error.js +0 -0
  128. /package/dist/es/{errors → lib/errors}/index.js +0 -0
  129. /package/dist/es/{errors → lib/errors}/integration-error.js +0 -0
  130. /package/dist/es/{errors → lib/errors}/library-usage-error.js +0 -0
  131. /package/dist/es/{errors → lib/errors}/parse-error-to-readable-json.js +0 -0
  132. /package/dist/es/{errors → lib/errors}/retry-request-error.js +0 -0
  133. /package/dist/es/{internal → lib/internal}/helpers/parallel-limit.js +0 -0
  134. /package/dist/es/{internal → lib/internal}/helpers/sanitize-object.js +0 -0
  135. /package/dist/es/{logging → lib/logging}/index.js +0 -0
  136. /package/dist/es/{logging → lib/logging}/logger.js +0 -0
  137. /package/dist/es/{requests → lib/requests}/index.js +0 -0
  138. /package/dist/es/{requests → lib/requests}/polarity-request.js +0 -0
  139. /package/dist/es/{requests → lib/requests}/sanitize-request-options.js +0 -0
@@ -1,4 +1,5 @@
1
1
  import Bottleneck from 'bottleneck';
2
+ import { z } from 'zod';
2
3
 
3
4
  /**
4
5
  * API error for REST requests
@@ -18,6 +19,24 @@ export declare class AuthRequestError extends IntegrationError {
18
19
  constructor(message: string, properties?: IntegrationErrorProperties);
19
20
  }
20
21
 
22
+ /**
23
+ * Cache operation options
24
+ */
25
+ export declare interface CacheOptions {
26
+ /** Time-to-live in seconds. If not specified, uses default TTL */
27
+ ttl?: number;
28
+ }
29
+
30
+ /**
31
+ * @public
32
+ */
33
+ export declare type Channel = z.infer<typeof ChannelSchema>;
34
+
35
+ declare const ChannelSchema: z.ZodObject<{
36
+ channel_name: z.ZodString;
37
+ id: z.ZodNumber;
38
+ }, z.core.$strip>;
39
+
21
40
  /**
22
41
  * @public
23
42
  */
@@ -31,6 +50,11 @@ export declare type ConfigRequestProxyOptions = {
31
50
  json?: undefined | boolean;
32
51
  };
33
52
 
53
+ /**
54
+ * @public
55
+ */
56
+ export declare type DoLookupResult<TDetails = unknown> = Result<TDetails>[];
57
+
34
58
  /**
35
59
  * User options object passed into the integration's `doLookup` method.
36
60
  *
@@ -52,17 +76,25 @@ export declare type ConfigRequestProxyOptions = {
52
76
  * ```
53
77
  * @public
54
78
  */
55
- export declare type DoLookupUserOptions = {
56
- [key: string]: PossibleUserOptionValue;
57
- };
79
+ export declare type DoLookupUserOptions = z.infer<typeof DoLookupUserOptionsSchema>;
80
+
81
+ declare const DoLookupUserOptionsSchema: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodUndefined, z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodObject<{
82
+ display: z.ZodString;
83
+ value: z.ZodString;
84
+ }, z.core.$strip>, z.ZodArray<z.ZodObject<{
85
+ display: z.ZodString;
86
+ value: z.ZodString;
87
+ }, z.core.$strip>>]>>;
58
88
 
59
89
  /**
60
90
  * @public
61
91
  */
62
- export declare type DropdownUserOptionValue = {
63
- display: string;
64
- value: string;
65
- };
92
+ export declare type DropdownUserOptionValue = z.infer<typeof DropdownUserOptionValueSchema>;
93
+
94
+ declare const DropdownUserOptionValueSchema: z.ZodObject<{
95
+ display: z.ZodString;
96
+ value: z.ZodString;
97
+ }, z.core.$strip>;
66
98
 
67
99
  /**
68
100
  * Represents a Polarity Entity object which is passed to an integration's
@@ -70,41 +102,48 @@ export declare type DropdownUserOptionValue = {
70
102
  *
71
103
  * @public
72
104
  */
73
- export declare type Entity = {
74
- value: string;
75
- types: EntityType[];
76
- type: EntityType;
77
- requestContext: {
78
- requestType: 'onDemand';
79
- isUserInitiated: boolean;
80
- };
81
- longitude: number;
82
- latitude: number;
83
- isURL: boolean;
84
- isSHA512: boolean;
85
- isSHA256: boolean;
86
- isSHA1: boolean;
87
- isPrivateIP: boolean;
88
- isMD5: boolean;
89
- isIPv6: boolean;
90
- isIPv4: boolean;
91
- isIP: boolean;
92
- isHex: boolean;
93
- isHash: boolean;
94
- isHTMLTag: boolean;
95
- isEmail: boolean;
96
- isDomain: boolean;
97
- hashType: string;
98
- displayValue: string;
99
- channels: string[];
100
- IPType: string;
101
- };
105
+ export declare type Entity = z.infer<typeof EntitySchema>;
106
+
107
+ declare const EntitySchema: z.ZodObject<{
108
+ value: z.ZodString;
109
+ types: z.ZodArray<z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodLiteral<"IP">, z.ZodLiteral<"IPv4">, z.ZodLiteral<"IPv4CIDR">, z.ZodLiteral<"IPv6">, z.ZodLiteral<"MAC">, z.ZodLiteral<"MD5">, z.ZodLiteral<"SHA1">, z.ZodLiteral<"SHA256">, z.ZodLiteral<"cve">, z.ZodLiteral<"domain">, z.ZodLiteral<"email">, z.ZodLiteral<"hash">, z.ZodLiteral<"string">, z.ZodLiteral<"url">]>, z.ZodLiteral<"*">, z.ZodLiteral<"custom">, z.ZodCustom<`custom.${string}`, `custom.${string}`>]>>;
110
+ type: z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodLiteral<"IP">, z.ZodLiteral<"IPv4">, z.ZodLiteral<"IPv4CIDR">, z.ZodLiteral<"IPv6">, z.ZodLiteral<"MAC">, z.ZodLiteral<"MD5">, z.ZodLiteral<"SHA1">, z.ZodLiteral<"SHA256">, z.ZodLiteral<"cve">, z.ZodLiteral<"domain">, z.ZodLiteral<"email">, z.ZodLiteral<"hash">, z.ZodLiteral<"string">, z.ZodLiteral<"url">]>, z.ZodLiteral<"*">, z.ZodLiteral<"custom">, z.ZodCustom<`custom.${string}`, `custom.${string}`>]>;
111
+ requestContext: z.ZodObject<{
112
+ requestType: z.ZodLiteral<"onDemand">;
113
+ isUserInitiated: z.ZodBoolean;
114
+ }, z.core.$strip>;
115
+ longitude: z.ZodNumber;
116
+ latitude: z.ZodNumber;
117
+ isURL: z.ZodBoolean;
118
+ isSHA512: z.ZodBoolean;
119
+ isSHA256: z.ZodBoolean;
120
+ isSHA1: z.ZodBoolean;
121
+ isPrivateIP: z.ZodBoolean;
122
+ isMD5: z.ZodBoolean;
123
+ isIPv6: z.ZodBoolean;
124
+ isIPv4: z.ZodBoolean;
125
+ isIP: z.ZodBoolean;
126
+ isHex: z.ZodBoolean;
127
+ isHash: z.ZodBoolean;
128
+ isHTMLTag: z.ZodBoolean;
129
+ isEmail: z.ZodBoolean;
130
+ isDomain: z.ZodBoolean;
131
+ hashType: z.ZodUnion<readonly [z.ZodLiteral<"md5">, z.ZodLiteral<"sha1">, z.ZodLiteral<"sha256">, z.ZodLiteral<"sha512">, z.ZodLiteral<"">]>;
132
+ displayValue: z.ZodString;
133
+ channels: z.ZodArray<z.ZodObject<{
134
+ channel_name: z.ZodString;
135
+ id: z.ZodNumber;
136
+ }, z.core.$strip>>;
137
+ IPType: z.ZodUnion<readonly [z.ZodLiteral<"IPv4">, z.ZodLiteral<"IPv6">, z.ZodLiteral<"">]>;
138
+ }, z.core.$strip>;
102
139
 
103
140
  /**
104
141
  * Entity Types including custom types
105
142
  * @public
106
143
  */
107
- export declare type EntityType = StandardEntityType | '*' | 'custom' | `custom.${string}`;
144
+ export declare type EntityType = z.infer<typeof EntityTypeSchema>;
145
+
146
+ declare const EntityTypeSchema: z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodLiteral<"IP">, z.ZodLiteral<"IPv4">, z.ZodLiteral<"IPv4CIDR">, z.ZodLiteral<"IPv6">, z.ZodLiteral<"MAC">, z.ZodLiteral<"MD5">, z.ZodLiteral<"SHA1">, z.ZodLiteral<"SHA256">, z.ZodLiteral<"cve">, z.ZodLiteral<"domain">, z.ZodLiteral<"email">, z.ZodLiteral<"hash">, z.ZodLiteral<"string">, z.ZodLiteral<"url">]>, z.ZodLiteral<"*">, z.ZodLiteral<"custom">, z.ZodCustom<`custom.${string}`, `custom.${string}`>]>;
108
147
 
109
148
  /**
110
149
  * @public
@@ -141,6 +180,39 @@ export declare type ErrorMeta = {
141
180
  */
142
181
  export declare const getLogger: () => Logger;
143
182
 
183
+ /**
184
+ * Global cache operations - shared across all integrations and users
185
+ * Use for system-wide statistics, feature flags, or shared configuration
186
+ */
187
+ export declare interface GlobalCache {
188
+ /**
189
+ * Get a value from global cache
190
+ * @param key - The cache key
191
+ * @returns Promise that resolves to the cached value or null if not found
192
+ * @example
193
+ * const totalLookups = await cache.global.get('total_lookups') || 0;
194
+ */
195
+ get(key: string): Promise<unknown>;
196
+ /**
197
+ * Set a value in global cache
198
+ * @param key - The cache key
199
+ * @param value - The value to cache (must be JSON serializable)
200
+ * @param options - Cache options including TTL
201
+ * @returns Promise that resolves when the operation completes
202
+ * @example
203
+ * await cache.global.set('total_lookups', count + 1, \{ ttl: 86400 \});
204
+ */
205
+ set(key: string, value: unknown, options?: CacheOptions): Promise<void>;
206
+ /**
207
+ * Delete a value from global cache
208
+ * @param key - The cache key to delete
209
+ * @returns Promise that resolves when the operation completes
210
+ * @example
211
+ * await cache.global.delete('feature_flags');
212
+ */
213
+ delete(key: string): Promise<void>;
214
+ }
215
+
144
216
  export declare type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'OPTIONS';
145
217
 
146
218
  /**
@@ -274,6 +346,178 @@ export declare type HttpRequestResponse = {
274
346
  [key: string]: unknown;
275
347
  };
276
348
 
349
+ export declare interface Integration<TStartupResult = unknown, TDetails = unknown> {
350
+ startup: (logger: Logger) => Promise<TStartupResult>;
351
+ doLookup: (entities: Entity[], options: DoLookupUserOptions, context: IntegrationContext) => Promise<DoLookupResult<TDetails> | IntegrationError | null | void>;
352
+ onMessage?: (payload: unknown, options: DoLookupUserOptions, context: IntegrationContext) => Promise<unknown>;
353
+ onDetails?: (lookupObject: Result<TDetails>, options: DoLookupUserOptions, context: IntegrationContext) => Promise<unknown>;
354
+ validateOptions: (options: ValidateOptionsUserOptions, context: IntegrationContext) => IntegrationError[];
355
+ }
356
+
357
+ /**
358
+ * Integration-scoped cache operations - shared across all users of a specific integration
359
+ * Use for API responses, configuration, or data that's the same for all users
360
+ */
361
+ export declare interface IntegrationCache {
362
+ /**
363
+ * Get a value from integration cache
364
+ * @param key - The cache key
365
+ * @returns Promise that resolves to the cached value or null if not found
366
+ * @example
367
+ * const config = await cache.integration.get('api_config');
368
+ */
369
+ get(key: string): Promise<unknown>;
370
+ /**
371
+ * Set a value in integration cache
372
+ * @param key - The cache key
373
+ * @param value - The value to cache (must be JSON serializable)
374
+ * @param options - Cache options including TTL
375
+ * @returns Promise that resolves when the operation completes
376
+ * @example
377
+ * await cache.integration.set('lookup_ip_1.1.1.1', result, \{ ttl: 300 \});
378
+ */
379
+ set(key: string, value: unknown, options?: CacheOptions): Promise<void>;
380
+ /**
381
+ * Delete a value from integration cache
382
+ * @param key - The cache key to delete
383
+ * @returns Promise that resolves when the operation completes
384
+ * @example
385
+ * await cache.integration.delete('expired_config');
386
+ */
387
+ delete(key: string): Promise<void>;
388
+ }
389
+
390
+ /**
391
+ * @public
392
+ */
393
+ export declare type IntegrationConfig = z.infer<typeof IntegrationConfigSchema>;
394
+
395
+ declare const IntegrationConfigSchema: z.ZodObject<{
396
+ polarityIntegrationUuid: z.ZodUUID;
397
+ name: z.ZodString;
398
+ acronym: z.ZodString;
399
+ description: z.ZodOptional<z.ZodString>;
400
+ defaultColor: z.ZodOptional<z.ZodString>;
401
+ entityTypes: z.ZodOptional<z.ZodArray<z.ZodString>>;
402
+ dataTypes: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
403
+ type: z.ZodOptional<z.ZodLiteral<"custom">>;
404
+ name: z.ZodOptional<z.ZodString>;
405
+ description: z.ZodOptional<z.ZodString>;
406
+ key: z.ZodString;
407
+ regex: z.ZodString;
408
+ editable: z.ZodOptional<z.ZodBoolean>;
409
+ enabled: z.ZodOptional<z.ZodBoolean>;
410
+ }, z.core.$strip>]>>>;
411
+ customTypes: z.ZodOptional<z.ZodArray<z.ZodObject<{
412
+ type: z.ZodOptional<z.ZodLiteral<"custom">>;
413
+ name: z.ZodOptional<z.ZodString>;
414
+ description: z.ZodOptional<z.ZodString>;
415
+ key: z.ZodString;
416
+ regex: z.ZodString;
417
+ editable: z.ZodOptional<z.ZodBoolean>;
418
+ enabled: z.ZodOptional<z.ZodBoolean>;
419
+ }, z.core.$strip>>>;
420
+ supportsAdditionalCustomTypes: z.ZodOptional<z.ZodBoolean>;
421
+ styles: z.ZodOptional<z.ZodArray<z.ZodString>>;
422
+ block: z.ZodObject<{
423
+ component: z.ZodObject<{
424
+ file: z.ZodString;
425
+ }, z.core.$strip>;
426
+ template: z.ZodObject<{
427
+ file: z.ZodString;
428
+ }, z.core.$strip>;
429
+ }, z.core.$strip>;
430
+ summary: z.ZodOptional<z.ZodObject<{
431
+ component: z.ZodObject<{
432
+ file: z.ZodString;
433
+ }, z.core.$strip>;
434
+ template: z.ZodObject<{
435
+ file: z.ZodString;
436
+ }, z.core.$strip>;
437
+ }, z.core.$strip>>;
438
+ onDemandOnly: z.ZodOptional<z.ZodBoolean>;
439
+ copyOnDemand: z.ZodOptional<z.ZodBoolean>;
440
+ logging: z.ZodOptional<z.ZodObject<{
441
+ level: z.ZodEnum<{
442
+ error: "error";
443
+ debug: "debug";
444
+ info: "info";
445
+ trace: "trace";
446
+ warn: "warn";
447
+ fatal: "fatal";
448
+ }>;
449
+ }, z.core.$strip>>;
450
+ request: z.ZodOptional<z.ZodObject<{
451
+ cert: z.ZodOptional<z.ZodString>;
452
+ key: z.ZodOptional<z.ZodString>;
453
+ passphrase: z.ZodOptional<z.ZodString>;
454
+ ca: z.ZodOptional<z.ZodString>;
455
+ proxy: z.ZodOptional<z.ZodString>;
456
+ rejectUnauthorized: z.ZodOptional<z.ZodBoolean>;
457
+ }, z.core.$strip>>;
458
+ options: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
459
+ type: z.ZodEnum<{
460
+ text: "text";
461
+ password: "password";
462
+ }>;
463
+ key: z.ZodString;
464
+ name: z.ZodString;
465
+ description: z.ZodOptional<z.ZodString>;
466
+ default: z.ZodNullable<z.ZodString>;
467
+ userCanEdit: z.ZodOptional<z.ZodBoolean>;
468
+ adminOnly: z.ZodOptional<z.ZodBoolean>;
469
+ }, z.core.$strip>, z.ZodObject<{
470
+ type: z.ZodLiteral<"boolean">;
471
+ key: z.ZodString;
472
+ name: z.ZodString;
473
+ description: z.ZodOptional<z.ZodString>;
474
+ default: z.ZodNullable<z.ZodBoolean>;
475
+ userCanEdit: z.ZodOptional<z.ZodBoolean>;
476
+ adminOnly: z.ZodOptional<z.ZodBoolean>;
477
+ }, z.core.$strip>, z.ZodObject<{
478
+ type: z.ZodLiteral<"number">;
479
+ key: z.ZodString;
480
+ name: z.ZodString;
481
+ description: z.ZodOptional<z.ZodString>;
482
+ default: z.ZodNullable<z.ZodNumber>;
483
+ userCanEdit: z.ZodOptional<z.ZodBoolean>;
484
+ adminOnly: z.ZodOptional<z.ZodBoolean>;
485
+ }, z.core.$strip>, z.ZodObject<{
486
+ type: z.ZodLiteral<"select">;
487
+ key: z.ZodString;
488
+ name: z.ZodString;
489
+ description: z.ZodOptional<z.ZodString>;
490
+ default: z.ZodNullable<z.ZodUnion<readonly [z.ZodObject<{
491
+ value: z.ZodString;
492
+ display: z.ZodString;
493
+ }, z.core.$strip>, z.ZodArray<z.ZodObject<{
494
+ value: z.ZodString;
495
+ display: z.ZodString;
496
+ }, z.core.$strip>>, z.ZodString]>>;
497
+ options: z.ZodArray<z.ZodObject<{
498
+ value: z.ZodString;
499
+ display: z.ZodString;
500
+ }, z.core.$strip>>;
501
+ multiple: z.ZodOptional<z.ZodBoolean>;
502
+ userCanEdit: z.ZodBoolean;
503
+ adminOnly: z.ZodBoolean;
504
+ }, z.core.$strip>], "type">>>;
505
+ }, z.core.$strip>;
506
+
507
+ /**
508
+ * Integration context provided to integration functions
509
+ */
510
+ export declare interface IntegrationContext {
511
+ /** Cache client for hierarchical caching operations */
512
+ cache: PolarityCache;
513
+ /** Integration identifier */
514
+ integrationId: string;
515
+ /** User identifier */
516
+ userId?: string;
517
+ /** Logger instance */
518
+ logger: Logger;
519
+ }
520
+
277
521
  /**
278
522
  * @public
279
523
  */
@@ -422,7 +666,7 @@ export declare class LibraryUsageError extends IntegrationError {
422
666
  /**
423
667
  * @public
424
668
  */
425
- export declare type Logger = {
669
+ declare type Logger = {
426
670
  child?(arg: unknown): Logger;
427
671
  info(...args: unknown[]): void;
428
672
  debug(...args: unknown[]): void;
@@ -431,6 +675,8 @@ export declare type Logger = {
431
675
  error(...args: unknown[]): void;
432
676
  fatal(...args: unknown[]): void;
433
677
  };
678
+ export { Logger }
679
+ export { Logger as PolarityLogger }
434
680
 
435
681
  /**
436
682
  * @public
@@ -455,6 +701,52 @@ export declare class NetworkError extends IntegrationError {
455
701
  */
456
702
  export declare const parseErrorToReadableJson: (error: Error_2) => any;
457
703
 
704
+ /**
705
+ * Main cache interface providing hierarchical caching with three scopes
706
+ *
707
+ * Cache Hierarchy:
708
+ * - Global: System-wide data shared across all integrations
709
+ * - Integration: Data shared among all users of a specific integration
710
+ * - User: User-specific data within an integration context
711
+ *
712
+ * Best Practices:
713
+ * - Use appropriate TTL values to prevent stale data
714
+ * - Handle cache misses gracefully (operations may return null)
715
+ * - Wrap cache operations in try/catch blocks
716
+ * - Use descriptive keys that won't conflict with other data
717
+ *
718
+ * @example
719
+ * ```javascript
720
+ * // In your integration functions:
721
+ * async function doLookup(entities, options, context) {
722
+ * const cache = context?.cache;
723
+ * if (!cache) return generateFreshData();
724
+ *
725
+ * try {
726
+ * // Check integration cache first
727
+ * const cached = await cache.integration.get(`lookup_${entity.value}`);
728
+ * if (cached) return cached;
729
+ *
730
+ * // Generate and cache new data
731
+ * const result = await apiCall(entity);
732
+ * await cache.integration.set(`lookup_${entity.value}`, result, { ttl: 300 });
733
+ * return result;
734
+ * } catch (error) {
735
+ * console.error('Cache error:', error);
736
+ * return generateFreshData(); // Fallback
737
+ * }
738
+ * }
739
+ * ```
740
+ */
741
+ export declare interface PolarityCache {
742
+ /** Global cache operations - shared across all integrations and users */
743
+ global: GlobalCache;
744
+ /** Integration-scoped cache operations - shared across all users of a specific integration */
745
+ integration: IntegrationCache;
746
+ /** User-scoped cache operations - specific to individual users */
747
+ user: UserCache;
748
+ }
749
+
458
750
  /**
459
751
  * A utility class for making HTTP requests
460
752
  * @public
@@ -657,7 +949,15 @@ export declare class PolarityRequest {
657
949
  /**
658
950
  * @public
659
951
  */
660
- export declare type PossibleUserOptionValue = undefined | string | number | boolean | DropdownUserOptionValue | DropdownUserOptionValue[];
952
+ export declare type PossibleUserOptionValue = z.infer<typeof PossibleUserOptionValueSchema>;
953
+
954
+ declare const PossibleUserOptionValueSchema: z.ZodUnion<readonly [z.ZodUndefined, z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodObject<{
955
+ display: z.ZodString;
956
+ value: z.ZodString;
957
+ }, z.core.$strip>, z.ZodArray<z.ZodObject<{
958
+ display: z.ZodString;
959
+ value: z.ZodString;
960
+ }, z.core.$strip>>]>;
661
961
 
662
962
  /**
663
963
  * @public
@@ -687,6 +987,56 @@ export declare class PolarityRequest {
687
987
  */
688
988
  export declare type PreprocessRequestOptions = (requestOptions: HttpRequestOptions, userOptions: DoLookupUserOptions) => Promise<HttpRequestOptions> | never | undefined;
689
989
 
990
+ /**
991
+ * @public
992
+ */
993
+ export declare type Result<TDetails = unknown> = Omit<z.infer<typeof ResultSchema>, 'data'> & {
994
+ data: {
995
+ summary: string[];
996
+ details: TDetails;
997
+ };
998
+ };
999
+
1000
+ declare const ResultSchema: z.ZodObject<{
1001
+ entity: z.ZodObject<{
1002
+ value: z.ZodString;
1003
+ types: z.ZodArray<z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodLiteral<"IP">, z.ZodLiteral<"IPv4">, z.ZodLiteral<"IPv4CIDR">, z.ZodLiteral<"IPv6">, z.ZodLiteral<"MAC">, z.ZodLiteral<"MD5">, z.ZodLiteral<"SHA1">, z.ZodLiteral<"SHA256">, z.ZodLiteral<"cve">, z.ZodLiteral<"domain">, z.ZodLiteral<"email">, z.ZodLiteral<"hash">, z.ZodLiteral<"string">, z.ZodLiteral<"url">]>, z.ZodLiteral<"*">, z.ZodLiteral<"custom">, z.ZodCustom<`custom.${string}`, `custom.${string}`>]>>;
1004
+ type: z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodLiteral<"IP">, z.ZodLiteral<"IPv4">, z.ZodLiteral<"IPv4CIDR">, z.ZodLiteral<"IPv6">, z.ZodLiteral<"MAC">, z.ZodLiteral<"MD5">, z.ZodLiteral<"SHA1">, z.ZodLiteral<"SHA256">, z.ZodLiteral<"cve">, z.ZodLiteral<"domain">, z.ZodLiteral<"email">, z.ZodLiteral<"hash">, z.ZodLiteral<"string">, z.ZodLiteral<"url">]>, z.ZodLiteral<"*">, z.ZodLiteral<"custom">, z.ZodCustom<`custom.${string}`, `custom.${string}`>]>;
1005
+ requestContext: z.ZodObject<{
1006
+ requestType: z.ZodLiteral<"onDemand">;
1007
+ isUserInitiated: z.ZodBoolean;
1008
+ }, z.core.$strip>;
1009
+ longitude: z.ZodNumber;
1010
+ latitude: z.ZodNumber;
1011
+ isURL: z.ZodBoolean;
1012
+ isSHA512: z.ZodBoolean;
1013
+ isSHA256: z.ZodBoolean;
1014
+ isSHA1: z.ZodBoolean;
1015
+ isPrivateIP: z.ZodBoolean;
1016
+ isMD5: z.ZodBoolean;
1017
+ isIPv6: z.ZodBoolean;
1018
+ isIPv4: z.ZodBoolean;
1019
+ isIP: z.ZodBoolean;
1020
+ isHex: z.ZodBoolean;
1021
+ isHash: z.ZodBoolean;
1022
+ isHTMLTag: z.ZodBoolean;
1023
+ isEmail: z.ZodBoolean;
1024
+ isDomain: z.ZodBoolean;
1025
+ hashType: z.ZodUnion<readonly [z.ZodLiteral<"md5">, z.ZodLiteral<"sha1">, z.ZodLiteral<"sha256">, z.ZodLiteral<"sha512">, z.ZodLiteral<"">]>;
1026
+ displayValue: z.ZodString;
1027
+ channels: z.ZodArray<z.ZodObject<{
1028
+ channel_name: z.ZodString;
1029
+ id: z.ZodNumber;
1030
+ }, z.core.$strip>>;
1031
+ IPType: z.ZodUnion<readonly [z.ZodLiteral<"IPv4">, z.ZodLiteral<"IPv6">, z.ZodLiteral<"">]>;
1032
+ }, z.core.$strip>;
1033
+ displayValue: z.ZodOptional<z.ZodString>;
1034
+ data: z.ZodObject<{
1035
+ summary: z.ZodArray<z.ZodString>;
1036
+ details: z.ZodUnknown;
1037
+ }, z.core.$strip>;
1038
+ }, z.core.$strip>;
1039
+
690
1040
  /**
691
1041
  * Thrown by authenticated request method for any HTTP status codes where we want to allow
692
1042
  * the user to retry their lookup.
@@ -821,32 +1171,89 @@ export declare class PolarityRequest {
821
1171
  * List of supported entity type values
822
1172
  * @public
823
1173
  */
824
- export declare type StandardEntityType = 'IP' | 'IPv4' | 'IPv4CIDR' | 'IPv6' | 'MAC' | 'MD5' | 'SHA1' | 'SHA256' | 'cve' | 'domain' | 'email' | 'hash' | 'string' | 'url';
1174
+ export declare type StandardEntityType = z.infer<typeof StandardEntityTypeSchema>;
1175
+
1176
+ declare const StandardEntityTypeSchema: z.ZodUnion<readonly [z.ZodLiteral<"IP">, z.ZodLiteral<"IPv4">, z.ZodLiteral<"IPv4CIDR">, z.ZodLiteral<"IPv6">, z.ZodLiteral<"MAC">, z.ZodLiteral<"MD5">, z.ZodLiteral<"SHA1">, z.ZodLiteral<"SHA256">, z.ZodLiteral<"cve">, z.ZodLiteral<"domain">, z.ZodLiteral<"email">, z.ZodLiteral<"hash">, z.ZodLiteral<"string">, z.ZodLiteral<"url">]>;
1177
+
1178
+ /**
1179
+ * User-scoped cache operations - specific to individual users
1180
+ * Use for user preferences, recent activity, or personalized data
1181
+ */
1182
+ export declare interface UserCache {
1183
+ /**
1184
+ * Get a value from user cache
1185
+ * @param key - The cache key
1186
+ * @returns Promise that resolves to the cached value or null if not found
1187
+ * @example
1188
+ * const preferences = await cache.user.get('preferences');
1189
+ */
1190
+ get(key: string): Promise<unknown>;
1191
+ /**
1192
+ * Set a value in user cache
1193
+ * @param key - The cache key
1194
+ * @param value - The value to cache (must be JSON serializable)
1195
+ * @param options - Cache options including TTL
1196
+ * @returns Promise that resolves when the operation completes
1197
+ * @example
1198
+ * await cache.user.set('recent_lookups', lookups, \{ ttl: 3600 \});
1199
+ */
1200
+ set(key: string, value: unknown, options?: CacheOptions): Promise<void>;
1201
+ /**
1202
+ * Delete a value from user cache
1203
+ * @param key - The cache key to delete
1204
+ * @returns Promise that resolves when the operation completes
1205
+ * @example
1206
+ * await cache.user.delete('preferences');
1207
+ */
1208
+ delete(key: string): Promise<void>;
1209
+ }
825
1210
 
826
1211
  /**
827
1212
  * @public
828
1213
  */
829
- export declare type ValidateOptionsUserOption = {
830
- integration_id?: string;
831
- key: string;
832
- value: PossibleUserOptionValue;
833
- user_can_edit?: boolean;
834
- admin_only?: boolean;
835
- };
1214
+ export declare type ValidateOptionsUserOption = z.infer<typeof ValidateOptionsUserOptionSchema>;
836
1215
 
837
1216
  /**
838
1217
  * @public
839
1218
  */
840
- export declare type ValidateOptionsUserOptions = {
841
- [key: string]: ValidateOptionsUserOption;
842
- };
1219
+ export declare type ValidateOptionsUserOptions = z.infer<typeof ValidateOptionsUserOptionsSchema>;
1220
+
1221
+ declare const ValidateOptionsUserOptionSchema: z.ZodObject<{
1222
+ integration_id: z.ZodOptional<z.ZodString>;
1223
+ key: z.ZodString;
1224
+ value: z.ZodUnion<readonly [z.ZodUndefined, z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodObject<{
1225
+ display: z.ZodString;
1226
+ value: z.ZodString;
1227
+ }, z.core.$strip>, z.ZodArray<z.ZodObject<{
1228
+ display: z.ZodString;
1229
+ value: z.ZodString;
1230
+ }, z.core.$strip>>]>;
1231
+ user_can_edit: z.ZodOptional<z.ZodBoolean>;
1232
+ admin_only: z.ZodOptional<z.ZodBoolean>;
1233
+ }, z.core.$strip>;
1234
+
1235
+ declare const ValidateOptionsUserOptionsSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
1236
+ integration_id: z.ZodOptional<z.ZodString>;
1237
+ key: z.ZodString;
1238
+ value: z.ZodUnion<readonly [z.ZodUndefined, z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodObject<{
1239
+ display: z.ZodString;
1240
+ value: z.ZodString;
1241
+ }, z.core.$strip>, z.ZodArray<z.ZodObject<{
1242
+ display: z.ZodString;
1243
+ value: z.ZodString;
1244
+ }, z.core.$strip>>]>;
1245
+ user_can_edit: z.ZodOptional<z.ZodBoolean>;
1246
+ admin_only: z.ZodOptional<z.ZodBoolean>;
1247
+ }, z.core.$strip>>;
843
1248
 
844
1249
  /**
845
1250
  * @public
846
1251
  */
847
- export declare type ValidationError = {
848
- key: string;
849
- message: string;
850
- };
1252
+ export declare type ValidationError = z.infer<typeof ValidationErrorSchema>;
1253
+
1254
+ declare const ValidationErrorSchema: z.ZodObject<{
1255
+ key: z.ZodString;
1256
+ message: z.ZodString;
1257
+ }, z.core.$strip>;
851
1258
 
852
1259
  export { }