polarity-integration-utils 0.1.0 → 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 (231) hide show
  1. package/README.md +30 -2
  2. package/dist/dts/context/cache.d.ts +149 -0
  3. package/dist/dts/context/cache.d.ts.map +1 -0
  4. package/dist/dts/context/index.d.ts +3 -0
  5. package/dist/dts/context/index.d.ts.map +1 -0
  6. package/dist/dts/context/integration-context.d.ts +16 -0
  7. package/dist/dts/context/integration-context.d.ts.map +1 -0
  8. package/dist/dts/errors/api-request-error.d.ts +10 -0
  9. package/dist/dts/errors/api-request-error.d.ts.map +1 -0
  10. package/dist/dts/errors/auth-request-error.d.ts +10 -0
  11. package/dist/dts/errors/auth-request-error.d.ts.map +1 -0
  12. package/dist/dts/errors/index.d.ts +8 -0
  13. package/dist/dts/errors/index.d.ts.map +1 -0
  14. package/dist/dts/errors/integration-error.d.ts +189 -0
  15. package/dist/dts/errors/integration-error.d.ts.map +1 -0
  16. package/dist/dts/errors/library-usage-error.d.ts +12 -0
  17. package/dist/dts/errors/library-usage-error.d.ts.map +1 -0
  18. package/dist/dts/errors/network-error.d.ts +11 -0
  19. package/dist/dts/errors/network-error.d.ts.map +1 -0
  20. package/dist/dts/errors/parse-error-to-readable-json.d.ts +7 -0
  21. package/dist/dts/errors/parse-error-to-readable-json.d.ts.map +1 -0
  22. package/dist/dts/errors/retry-request-error.d.ts +11 -0
  23. package/dist/dts/errors/retry-request-error.d.ts.map +1 -0
  24. package/dist/dts/index.d.ts +8 -0
  25. package/dist/dts/index.d.ts.map +1 -0
  26. package/dist/dts/index.docs.d.ts +10 -0
  27. package/dist/dts/index.docs.d.ts.map +1 -0
  28. package/dist/dts/internal/helpers/parallel-limit.d.ts +9 -0
  29. package/dist/dts/internal/helpers/parallel-limit.d.ts.map +1 -0
  30. package/dist/dts/internal/helpers/sanitize-object.d.ts +11 -0
  31. package/dist/dts/internal/helpers/sanitize-object.d.ts.map +1 -0
  32. package/dist/dts/lib/context/cache.d.ts +149 -0
  33. package/dist/dts/lib/context/cache.d.ts.map +1 -0
  34. package/dist/dts/lib/context/index.d.ts +3 -0
  35. package/dist/dts/lib/context/index.d.ts.map +1 -0
  36. package/dist/dts/lib/context/integration-context.d.ts +16 -0
  37. package/dist/dts/lib/context/integration-context.d.ts.map +1 -0
  38. package/dist/dts/lib/errors/api-request-error.d.ts +10 -0
  39. package/dist/dts/lib/errors/api-request-error.d.ts.map +1 -0
  40. package/dist/dts/lib/errors/auth-request-error.d.ts +10 -0
  41. package/dist/dts/lib/errors/auth-request-error.d.ts.map +1 -0
  42. package/dist/dts/lib/errors/index.d.ts +8 -0
  43. package/dist/dts/lib/errors/index.d.ts.map +1 -0
  44. package/dist/dts/lib/errors/integration-error.d.ts +189 -0
  45. package/dist/dts/lib/errors/integration-error.d.ts.map +1 -0
  46. package/dist/dts/lib/errors/library-usage-error.d.ts +12 -0
  47. package/dist/dts/lib/errors/library-usage-error.d.ts.map +1 -0
  48. package/dist/dts/lib/errors/network-error.d.ts +11 -0
  49. package/dist/dts/lib/errors/network-error.d.ts.map +1 -0
  50. package/dist/dts/lib/errors/parse-error-to-readable-json.d.ts +7 -0
  51. package/dist/dts/lib/errors/parse-error-to-readable-json.d.ts.map +1 -0
  52. package/dist/dts/lib/errors/retry-request-error.d.ts +11 -0
  53. package/dist/dts/lib/errors/retry-request-error.d.ts.map +1 -0
  54. package/dist/dts/lib/index.d.ts +8 -0
  55. package/dist/dts/lib/index.d.ts.map +1 -0
  56. package/dist/dts/lib/index.docs.d.ts +10 -0
  57. package/dist/dts/lib/index.docs.d.ts.map +1 -0
  58. package/dist/dts/lib/internal/helpers/parallel-limit.d.ts +9 -0
  59. package/dist/dts/lib/internal/helpers/parallel-limit.d.ts.map +1 -0
  60. package/dist/dts/lib/internal/helpers/sanitize-object.d.ts +11 -0
  61. package/dist/dts/lib/internal/helpers/sanitize-object.d.ts.map +1 -0
  62. package/dist/dts/lib/logging/index.d.ts +2 -0
  63. package/dist/dts/lib/logging/index.d.ts.map +1 -0
  64. package/dist/dts/lib/logging/logger.d.ts +49 -0
  65. package/dist/dts/lib/logging/logger.d.ts.map +1 -0
  66. package/dist/dts/lib/requests/index.d.ts +3 -0
  67. package/dist/dts/lib/requests/index.d.ts.map +1 -0
  68. package/dist/dts/lib/requests/polarity-request.d.ts +411 -0
  69. package/dist/dts/lib/requests/polarity-request.d.ts.map +1 -0
  70. package/dist/dts/lib/requests/sanitize-request-options.d.ts +20 -0
  71. package/dist/dts/lib/requests/sanitize-request-options.d.ts.map +1 -0
  72. package/dist/dts/lib/testing/enhanced-utils/create-entity.d.ts +3 -0
  73. package/dist/dts/lib/testing/enhanced-utils/create-entity.d.ts.map +1 -0
  74. package/dist/dts/lib/testing/enhanced-utils/create-mock-integration-context.d.ts +3 -0
  75. package/dist/dts/lib/testing/enhanced-utils/create-mock-integration-context.d.ts.map +1 -0
  76. package/dist/dts/lib/testing/enhanced-utils/mock-request.d.ts +14 -0
  77. package/dist/dts/lib/testing/enhanced-utils/mock-request.d.ts.map +1 -0
  78. package/dist/dts/lib/testing/enhanced-utils/validate-integration.d.ts +8 -0
  79. package/dist/dts/lib/testing/enhanced-utils/validate-integration.d.ts.map +1 -0
  80. package/dist/dts/lib/testing/index.d.ts +6 -0
  81. package/dist/dts/lib/testing/index.d.ts.map +1 -0
  82. package/dist/dts/lib/testing/test-factory/create-integration-tests.d.ts +6 -0
  83. package/dist/dts/lib/testing/test-factory/create-integration-tests.d.ts.map +1 -0
  84. package/dist/dts/lib/testing/test-factory/test-do-lookup.d.ts +7 -0
  85. package/dist/dts/lib/testing/test-factory/test-do-lookup.d.ts.map +1 -0
  86. package/dist/dts/lib/testing/test-factory/test-on-message.d.ts +8 -0
  87. package/dist/dts/lib/testing/test-factory/test-on-message.d.ts.map +1 -0
  88. package/dist/dts/lib/types.d.ts +101 -0
  89. package/dist/dts/lib/types.d.ts.map +1 -0
  90. package/dist/dts/lib/zod-types.d.ts +278 -0
  91. package/dist/dts/lib/zod-types.d.ts.map +1 -0
  92. package/dist/dts/logging/index.d.ts +2 -0
  93. package/dist/dts/logging/index.d.ts.map +1 -0
  94. package/dist/dts/logging/logger.d.ts +49 -0
  95. package/dist/dts/logging/logger.d.ts.map +1 -0
  96. package/dist/dts/requests/index.d.ts +3 -0
  97. package/dist/dts/requests/index.d.ts.map +1 -0
  98. package/dist/dts/requests/polarity-request.d.ts +411 -0
  99. package/dist/dts/requests/polarity-request.d.ts.map +1 -0
  100. package/dist/dts/requests/sanitize-request-options.d.ts +20 -0
  101. package/dist/dts/requests/sanitize-request-options.d.ts.map +1 -0
  102. package/dist/dts/testing/enhanced-utils/create-entity.d.ts +3 -0
  103. package/dist/dts/testing/enhanced-utils/create-entity.d.ts.map +1 -0
  104. package/dist/dts/testing/enhanced-utils/create-mock-integration-context.d.ts +3 -0
  105. package/dist/dts/testing/enhanced-utils/create-mock-integration-context.d.ts.map +1 -0
  106. package/dist/dts/testing/enhanced-utils/mock-request.d.ts +14 -0
  107. package/dist/dts/testing/enhanced-utils/mock-request.d.ts.map +1 -0
  108. package/dist/dts/testing/enhanced-utils/validate-integration.d.ts +8 -0
  109. package/dist/dts/testing/enhanced-utils/validate-integration.d.ts.map +1 -0
  110. package/dist/dts/testing/index.d.ts +6 -0
  111. package/dist/dts/testing/index.d.ts.map +1 -0
  112. package/dist/dts/testing/test-factory/create-integration-tests.d.ts +6 -0
  113. package/dist/dts/testing/test-factory/create-integration-tests.d.ts.map +1 -0
  114. package/dist/dts/testing/test-factory/test-do-lookup.d.ts +7 -0
  115. package/dist/dts/testing/test-factory/test-do-lookup.d.ts.map +1 -0
  116. package/dist/dts/testing/test-factory/test-on-message.d.ts +8 -0
  117. package/dist/dts/testing/test-factory/test-on-message.d.ts.map +1 -0
  118. package/dist/dts/tsdoc-metadata.json +11 -0
  119. package/dist/dts/types.d.ts +101 -0
  120. package/dist/dts/types.d.ts.map +1 -0
  121. package/dist/dts/zod-types.d.ts +278 -0
  122. package/dist/dts/zod-types.d.ts.map +1 -0
  123. package/dist/es/lib/context/index.js +18 -0
  124. package/dist/es/lib/errors/api-request-error.js +15 -0
  125. package/dist/es/lib/errors/auth-request-error.js +15 -0
  126. package/dist/es/lib/errors/index.js +23 -0
  127. package/dist/es/lib/errors/integration-error.js +116 -0
  128. package/dist/es/lib/errors/library-usage-error.js +17 -0
  129. package/dist/es/lib/errors/network-error.js +88 -0
  130. package/dist/es/lib/errors/parse-error-to-readable-json.js +9 -0
  131. package/dist/es/lib/errors/retry-request-error.js +16 -0
  132. package/dist/es/lib/index.docs.js +25 -0
  133. package/dist/es/lib/index.js +50 -0
  134. package/dist/es/lib/internal/helpers/parallel-limit.js +36 -0
  135. package/dist/es/lib/internal/helpers/sanitize-object.js +37 -0
  136. package/dist/es/lib/logging/index.js +17 -0
  137. package/dist/es/lib/logging/logger.js +53 -0
  138. package/dist/es/lib/requests/index.js +18 -0
  139. package/dist/es/lib/requests/polarity-request.js +426 -0
  140. package/dist/es/lib/requests/sanitize-request-options.js +50 -0
  141. package/dist/es/lib/testing/enhanced-utils/create-entity.js +37 -0
  142. package/dist/es/lib/testing/enhanced-utils/create-mock-integration-context.js +36 -0
  143. package/dist/es/lib/testing/enhanced-utils/mock-request.js +22 -0
  144. package/dist/es/lib/testing/enhanced-utils/validate-integration.js +159 -0
  145. package/dist/es/lib/testing/index.js +21 -0
  146. package/dist/es/lib/testing/test-factory/create-integration-tests.js +53 -0
  147. package/dist/es/lib/testing/test-factory/test-do-lookup.js +24 -0
  148. package/dist/es/lib/testing/test-factory/test-on-message.js +24 -0
  149. package/dist/es/lib/types.js +5 -0
  150. package/dist/es/lib/zod-types.js +206 -0
  151. package/dist/lib/context/cache.js +2 -0
  152. package/dist/lib/context/index.js +18 -0
  153. package/dist/lib/context/integration-context.js +2 -0
  154. package/dist/lib/errors/api-request-error.js +15 -0
  155. package/dist/lib/errors/auth-request-error.js +15 -0
  156. package/dist/lib/errors/index.js +20 -8
  157. package/dist/lib/errors/integration-error.js +116 -0
  158. package/dist/lib/errors/library-usage-error.js +17 -0
  159. package/dist/lib/errors/network-error.js +88 -0
  160. package/dist/lib/errors/parse-error-to-readable-json.js +9 -0
  161. package/dist/lib/errors/retry-request-error.js +16 -0
  162. package/dist/lib/index.docs.js +25 -0
  163. package/dist/lib/index.js +47 -13
  164. package/dist/lib/internal/helpers/parallel-limit.js +36 -0
  165. package/dist/lib/internal/helpers/sanitize-object.js +37 -0
  166. package/dist/lib/logging/index.js +15 -2
  167. package/dist/lib/logging/logger.js +41 -5
  168. package/dist/lib/requests/index.js +15 -8
  169. package/dist/lib/requests/polarity-request.js +426 -0
  170. package/dist/lib/requests/sanitize-request-options.js +50 -0
  171. package/dist/lib/testing/enhanced-utils/create-entity.js +37 -0
  172. package/dist/lib/testing/enhanced-utils/create-mock-integration-context.js +36 -0
  173. package/dist/lib/testing/enhanced-utils/mock-request.js +22 -0
  174. package/dist/lib/testing/enhanced-utils/validate-integration.js +159 -0
  175. package/dist/lib/testing/index.js +21 -0
  176. package/dist/lib/testing/test-factory/create-integration-tests.js +53 -0
  177. package/dist/lib/testing/test-factory/test-do-lookup.js +24 -0
  178. package/dist/lib/testing/test-factory/test-on-message.js +24 -0
  179. package/dist/lib/types.js +5 -0
  180. package/dist/lib/zod-types.js +206 -0
  181. package/dist/polarity-integration-utils.d.ts +1259 -0
  182. package/package.json +81 -11
  183. package/dist/es/errors/RequestError.js +0 -12
  184. package/dist/es/errors/index.js +0 -11
  185. package/dist/es/errors/parseErrorToReadableJson.js +0 -4
  186. package/dist/es/helpers/async/index.js +0 -9
  187. package/dist/es/helpers/async/parallelLimit.js +0 -33
  188. package/dist/es/helpers/encodings/decodeBase64.js +0 -4
  189. package/dist/es/helpers/encodings/encodeBase64.js +0 -4
  190. package/dist/es/helpers/encodings/index.js +0 -11
  191. package/dist/es/helpers/index.js +0 -10
  192. package/dist/es/helpers/json/and.js +0 -4
  193. package/dist/es/helpers/json/filterObjectsContainingString.js +0 -10
  194. package/dist/es/helpers/json/index.js +0 -17
  195. package/dist/es/helpers/json/mapOverObject.js +0 -24
  196. package/dist/es/helpers/json/or.js +0 -4
  197. package/dist/es/helpers/json/transpose2dArray.js +0 -8
  198. package/dist/es/helpers/time/index.js +0 -11
  199. package/dist/es/helpers/time/millisecondsToHoursMinutesAndSeconds.js +0 -18
  200. package/dist/es/helpers/time/sleep.js +0 -13
  201. package/dist/es/index.js +0 -16
  202. package/dist/es/logging/index.js +0 -4
  203. package/dist/es/logging/logger.js +0 -17
  204. package/dist/es/requests/createRequestWithDefaults.js +0 -166
  205. package/dist/es/requests/createRequestsInParallel.js +0 -40
  206. package/dist/es/requests/index.js +0 -11
  207. package/dist/es/user-options/index.js +0 -9
  208. package/dist/es/user-options/validateUrlOption.js +0 -77
  209. package/dist/lib/errors/RequestError.js +0 -12
  210. package/dist/lib/errors/parseErrorToReadableJson.js +0 -4
  211. package/dist/lib/helpers/async/index.js +0 -9
  212. package/dist/lib/helpers/async/parallelLimit.js +0 -33
  213. package/dist/lib/helpers/encodings/decodeBase64.js +0 -4
  214. package/dist/lib/helpers/encodings/encodeBase64.js +0 -4
  215. package/dist/lib/helpers/encodings/index.js +0 -11
  216. package/dist/lib/helpers/index.js +0 -10
  217. package/dist/lib/helpers/json/and.js +0 -4
  218. package/dist/lib/helpers/json/filterObjectsContainingString.js +0 -10
  219. package/dist/lib/helpers/json/index.js +0 -17
  220. package/dist/lib/helpers/json/mapOverObject.js +0 -24
  221. package/dist/lib/helpers/json/or.js +0 -4
  222. package/dist/lib/helpers/json/transpose2dArray.js +0 -8
  223. package/dist/lib/helpers/time/index.js +0 -11
  224. package/dist/lib/helpers/time/millisecondsToHoursMinutesAndSeconds.js +0 -18
  225. package/dist/lib/helpers/time/sleep.js +0 -13
  226. package/dist/lib/requests/createRequestWithDefaults.js +0 -166
  227. package/dist/lib/requests/createRequestsInParallel.js +0 -40
  228. package/dist/lib/user-options/index.js +0 -9
  229. package/dist/lib/user-options/validateUrlOption.js +0 -77
  230. /package/dist/es/{requests/requestTypes.js → lib/context/cache.js} +0 -0
  231. /package/dist/{lib/requests/requestTypes.js → es/lib/context/integration-context.js} +0 -0
@@ -0,0 +1,1259 @@
1
+ import Bottleneck from 'bottleneck';
2
+ import { z } from 'zod';
3
+
4
+ /**
5
+ * API error for REST requests
6
+ *
7
+ * @public
8
+ */
9
+ export declare class ApiRequestError extends IntegrationError {
10
+ constructor(message: string, properties?: IntegrationErrorProperties);
11
+ }
12
+
13
+ /**
14
+ * Thrown by generateAccessToken method if there is a failure to fetch a token
15
+ *
16
+ * @public
17
+ */
18
+ export declare class AuthRequestError extends IntegrationError {
19
+ constructor(message: string, properties?: IntegrationErrorProperties);
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
+
40
+ /**
41
+ * @public
42
+ */
43
+ export declare type ConfigRequestProxyOptions = {
44
+ ca?: undefined | string;
45
+ cert?: undefined | string;
46
+ key?: undefined | string;
47
+ passphrase?: undefined | string;
48
+ rejectUnauthorized?: undefined | boolean;
49
+ proxy?: undefined | string;
50
+ json?: undefined | boolean;
51
+ };
52
+
53
+ /**
54
+ * @public
55
+ */
56
+ export declare type DoLookupResult<TDetails = unknown> = Result<TDetails>[];
57
+
58
+ /**
59
+ * User options object passed into the integration's `doLookup` method.
60
+ *
61
+ * @example
62
+ * Example of the user options object passed into `doLookup`
63
+ * ```js
64
+ * function doLookup(entities, options, cb){
65
+ * // options here is of type DoLookupUserOptions
66
+ * }
67
+ * ```
68
+ *
69
+ * @example
70
+ * As an example, if your integration has a user option with a `key` value of
71
+ * `apiKey` within its `config.json`, the user options object passed into the `doLookup` method would look like:
72
+ * ```json
73
+ * {
74
+ * "apiKey": "XXXXXXXXXX"
75
+ * }
76
+ * ```
77
+ * @public
78
+ */
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>>]>>;
88
+
89
+ /**
90
+ * @public
91
+ */
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>;
98
+
99
+ /**
100
+ * Represents a Polarity Entity object which is passed to an integration's
101
+ * doLookup method.
102
+ *
103
+ * @public
104
+ */
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>;
139
+
140
+ /**
141
+ * Entity Types including custom types
142
+ * @public
143
+ */
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}`>]>;
147
+
148
+ /**
149
+ * @public
150
+ */
151
+ declare interface Error_2 {
152
+ name: string;
153
+ message: string;
154
+ stack?: string;
155
+ code?: number | string;
156
+ }
157
+ export { Error_2 as Error }
158
+
159
+ /**
160
+ * @public
161
+ */
162
+ export declare type ErrorMeta = {
163
+ [otherMetadata: string]: unknown;
164
+ };
165
+
166
+ /**
167
+ * return the logger object set via the {@link setLogger} method.
168
+ *
169
+ * @example
170
+ * Example of using the integration's logging object:
171
+ * ```js
172
+ * const { getLogger } = require('polarity-integration-utils/logger');
173
+ *
174
+ * const logger = getLogger();
175
+ * logger.trace('this is a trace message');
176
+ * ```
177
+ *
178
+ * @public
179
+ * @returns the integration's logger object
180
+ */
181
+ export declare const getLogger: () => Logger;
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
+
216
+ export declare type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'OPTIONS';
217
+
218
+ /**
219
+ * @public
220
+ */
221
+ export declare type HttpRequestOptions = {
222
+ /**
223
+ * The URL to make the request to.
224
+ */
225
+ url?: string;
226
+ /**
227
+ * The HTTP method to use for the request.
228
+ *
229
+ * @defaultValue 'GET'
230
+ */
231
+ method?: HttpMethod;
232
+ /**
233
+ * If true, sets body to JSON representation of value and adds Content-type: application/json header.
234
+ * Additionally, parses the response body as JSON.
235
+ *
236
+ * @defaultValue true
237
+ */
238
+ json?: boolean;
239
+ /**
240
+ * An object containing the headers to include in the request.
241
+ * @example
242
+ * Here is an example of setting the "X-Api-Key" `headers` property:
243
+ * ```
244
+ * {
245
+ * headers: {
246
+ * 'X-Api-Key': '1234567890'
247
+ * }
248
+ * }
249
+ * ```
250
+ */
251
+ headers?: object;
252
+ /**
253
+ * An object containing querystring parameters to include in the request.
254
+ * @example
255
+ * Here is an example of setting the `qs` property:
256
+ * ```
257
+ * {
258
+ * qs: {
259
+ * search: 'foo'
260
+ * }
261
+ * }
262
+ * ```
263
+ */
264
+ qs?: object;
265
+ /**
266
+ * When passed an object or a querystring, this sets body to a querystring representation of value,
267
+ * and adds Content-type: application/x-www-form-urlencoded header.
268
+ */
269
+ form?: object;
270
+ /**
271
+ * The body of the request.
272
+ */
273
+ body?: object;
274
+ /**
275
+ * The authentication options to use for the request
276
+ */
277
+ auth?: {
278
+ username: string;
279
+ password: string;
280
+ sendImmediately?: boolean;
281
+ } | {
282
+ bearer: string;
283
+ sendImmediately?: boolean;
284
+ };
285
+ [key: string]: unknown;
286
+ } & ({
287
+ entity: Entity;
288
+ entities?: never;
289
+ requestId?: never;
290
+ } | {
291
+ entities: Entity[];
292
+ entity?: never;
293
+ requestId?: never;
294
+ } | {
295
+ requestId: string | unknown;
296
+ entity?: never;
297
+ entities?: never;
298
+ } | {
299
+ entity?: never;
300
+ entities?: never;
301
+ requestId?: never;
302
+ });
303
+
304
+ /**
305
+ * @public
306
+ */
307
+ export declare type HttpRequestResponse = {
308
+ /**
309
+ * The HTTP status code of the response.
310
+ */
311
+ statusCode: number;
312
+ request: {
313
+ uri: unknown;
314
+ method: string;
315
+ headers: unknown;
316
+ [key: string]: unknown;
317
+ };
318
+ /**
319
+ * The body of the response.
320
+ */
321
+ body: unknown;
322
+ /**
323
+ * The response headers
324
+ */
325
+ headers: unknown;
326
+ /**
327
+ * The error object if an error occurred during the request.
328
+ */
329
+ error?: ApiRequestError | NetworkError | RetryRequestError;
330
+ /**
331
+ * The entity that the request was made for. The `entity` property matches the
332
+ * `entity` property set on the {@link HttpRequestOptions} object associated with this HttpRequestResponse.
333
+ */
334
+ entity?: Entity;
335
+ /**
336
+ * An array of entities that the request was made for. The `entities` property
337
+ * matches the `entities` property set on the {@link HttpRequestOptions} object associated
338
+ * with this HttpRequestResponse.
339
+ */
340
+ entities?: Entity[];
341
+ /**
342
+ * A custom request id that can be used to identify the request. The `requestId` matches
343
+ * the `requestId` property set on the {@link HttpRequestOptions} object.
344
+ */
345
+ requestId?: string | unknown;
346
+ [key: string]: unknown;
347
+ };
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
+
521
+ /**
522
+ * @public
523
+ */
524
+ export declare class IntegrationError extends Error {
525
+ /**
526
+ * a short, human-readable summary of the problem that SHOULD NOT change from occurrence to occurrence of
527
+ * the problem except for purposes of localization.
528
+ */
529
+ readonly title: string;
530
+ /**
531
+ * a human-readable explanation specific to this occurrence of the problem. Like title, this field’s value can be
532
+ * localized
533
+ */
534
+ readonly detail: string;
535
+ /**
536
+ * a meta object containing non-standard meta-information about the error.
537
+ */
538
+ readonly meta: ErrorMeta;
539
+ /**
540
+ * The HTTP status code applicable to this error, expressed as a string value.
541
+ */
542
+ readonly status: string;
543
+ /**
544
+ * an application-specific error code, expressed as a string value.
545
+ */
546
+ readonly code: string;
547
+ /**
548
+ * The `cause` property is used to specify the `cause` of the error. Typically,
549
+ * this property is used to pass through a related Error instance.
550
+ */
551
+ readonly cause: Error_2;
552
+ /**
553
+ * Additional details related to the error that may help the user troubleshoot the issue. If set by the user
554
+ * via the Error constructor, the user provided value will override any automated help message set by the
555
+ * Error class.
556
+ */
557
+ readonly help: string;
558
+ /**
559
+ * Relevant for integration errors involving a network call, the `requestOptions` property
560
+ * details the request options that resulted in the specified error. The `requestOptions` property will automatically
561
+ * have sensitive authentication headers stripped.
562
+ */
563
+ readonly requestOptions?: HttpRequestOptions;
564
+ /**
565
+ * Construct a new IntegrationError object.
566
+ * @param message - A string description of the error which is used as the `detail` property on the
567
+ * serialized error.
568
+ * @param properties - Optional properties for the error.
569
+ */
570
+ constructor(message: string, properties?: IntegrationErrorProperties);
571
+ /**
572
+ * Serializes the error's properties into a POJO. The order of the
573
+ * properties is preserved when serialized.
574
+ * @returns JSON representation of the error
575
+ */
576
+ toJSON(): SerializedIntegrationError;
577
+ }
578
+
579
+ /**
580
+ * @public
581
+ */
582
+ export declare interface IntegrationErrorProperties {
583
+ /**
584
+ * a short, human-readable summary of the problem that SHOULD NOT change from occurrence to occurrence of
585
+ * the problem except for purposes of localization. If omitted, the title will default to the type
586
+ * of error (e.g., IntegrationError, or ApiRequestError)
587
+ */
588
+ title?: string;
589
+ /**
590
+ * Additional details related to the error that may help the user troubleshoot the issue. If set by the user
591
+ * via the Error constructor, the user provided value will override any automated help message set by the
592
+ * Error class.
593
+ */
594
+ help?: string;
595
+ /**
596
+ * The `cause` property is used to specify the `cause` of the error. Typically,
597
+ * this property is used to pass through a related Error instance.
598
+ */
599
+ cause?: Error_2;
600
+ /**
601
+ * The HTTP status code applicable to this error, expressed as a string value.
602
+ */
603
+ status?: string;
604
+ /**
605
+ * an application-specific error code, expressed as a string value.
606
+ */
607
+ code?: string;
608
+ /**
609
+ * Relevant for integration errors involving a network call, the `requestOptions` property
610
+ * details the request options that resulted in the specified error. The `requestOptions` property will automatically
611
+ * have sensitive authentication headers stripped.
612
+ * By default, the following paths are sanitized:
613
+ *
614
+ * - auth.password
615
+ * - auth.bearer
616
+ * - body.password
617
+ * - form.client_secret
618
+ * - headers.authorization
619
+ * - headers.x-api-key
620
+ *
621
+ * Additional paths can be sanitized by using the `requestOptionsToSanitize` property.
622
+ */
623
+ requestOptions?: HttpRequestOptions;
624
+ /**
625
+ * List of paths in JSON dot notation to sanitize in the requestOptions object
626
+ */
627
+ requestOptionsToSanitize?: string[];
628
+ /**
629
+ * Any additional properties which will be appended to the Error's meta property
630
+ */
631
+ meta?: MetaObject;
632
+ }
633
+
634
+ /**
635
+ * @public
636
+ */
637
+ export declare type IsApiErrorFunction = (response: HttpRequestResponse, requestOptions: HttpRequestOptions, userOptions: DoLookupUserOptions) => IsApiErrorResult;
638
+
639
+ /**
640
+ * @public
641
+ */
642
+ export declare type IsApiErrorResult = {
643
+ /**
644
+ * Indicates whether the response is an API error.
645
+ */
646
+ isApiError: boolean;
647
+ /**
648
+ * Optional message providing additional information about the API error. The
649
+ * returned `message` will be used as the `message` property on the {@link ApiRequestError} object
650
+ * thrown by the request.
651
+ */
652
+ message?: string;
653
+ };
654
+
655
+ /**
656
+ * Thrown when the polarity-integration-utils library is used incorrectly. For example,
657
+ * if a method is called with incorrect or missing parameters, or a required initialization
658
+ * method is not called. This Error class should not be used directly by integrations.
659
+ *
660
+ * @public
661
+ */
662
+ export declare class LibraryUsageError extends IntegrationError {
663
+ constructor(message: string, properties?: IntegrationErrorProperties);
664
+ }
665
+
666
+ /**
667
+ * @public
668
+ */
669
+ declare type Logger = {
670
+ child?(arg: unknown): Logger;
671
+ info(...args: unknown[]): void;
672
+ debug(...args: unknown[]): void;
673
+ trace(...args: unknown[]): void;
674
+ warn(...args: unknown[]): void;
675
+ error(...args: unknown[]): void;
676
+ fatal(...args: unknown[]): void;
677
+ };
678
+ export { Logger }
679
+ export { Logger as PolarityLogger }
680
+
681
+ /**
682
+ * @public
683
+ */
684
+ export declare type MetaObject = {
685
+ [key: string]: unknown;
686
+ };
687
+
688
+ /**
689
+ * Generic network error for REST requests.
690
+ * https://betterstack.com/community/guides/scaling-nodejs/nodejs-errors/#4-econnrefused
691
+ *
692
+ * @public
693
+ */
694
+ export declare class NetworkError extends IntegrationError {
695
+ constructor(message: string, properties?: IntegrationErrorProperties);
696
+ }
697
+
698
+ /**
699
+ * @public
700
+ * @param error - Error instance to parse into a plain old javascript object
701
+ */
702
+ export declare const parseErrorToReadableJson: (error: Error_2) => any;
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
+
750
+ /**
751
+ * A utility class for making HTTP requests
752
+ * @public
753
+ */
754
+ export declare class PolarityRequest {
755
+ private bottleneckLimiter;
756
+ /**
757
+ * Instance of a Bunyan logger
758
+ */
759
+ private logger;
760
+ private internalThrottlingOptions;
761
+ /**
762
+ * postman-request library request object with default values set. Used internally for
763
+ * making HTTP requests directly via the postman-request library
764
+ */
765
+ private readonly requestWithDefaults;
766
+ readonly roundedSuccessStatusCodes: number[];
767
+ /**
768
+ * One or more HTTP response properties specified using JSON dot notation. If the
769
+ * specified path exists within the `body` property of the HTTP Response, an
770
+ * ApiRequestError will be thrown.
771
+ *
772
+ * By default, this value is an empty array and response properties are not used to
773
+ * detect errors.
774
+ * @defaultValue []
775
+ */
776
+ readonly httpResponseErrorProperties: string[];
777
+ /**
778
+ * One or more HTTP response properties specified using JSON dot notation that
779
+ * point to an error message that should be displayed to the user in the event
780
+ * of an API error.
781
+ *
782
+ * The property should be a string value. If the property does not exist or is not
783
+ * a string value, a default error message will be used instead.
784
+ */
785
+ readonly httpResponseErrorMessageProperties: string[];
786
+ /**
787
+ * Optional method that can be implemented to determine if an API error
788
+ * was encountered after an HTTP request is made.
789
+ *
790
+ * If the `isApiError` method is implemented
791
+ * the property `roundedSuccessStatusCodes` and `httpResponseErrorProperties` are not
792
+ * used to determine API errors.
793
+ *
794
+ * @returns An object indicating whether an API error was encountered and an optional message.
795
+ */
796
+ readonly isApiError: IsApiErrorFunction;
797
+ /**
798
+ * An array of JSON dot notation paths to omit from the request options when logging.
799
+ *
800
+ * This property can be used to sanitize sensitive request properties that should not
801
+ * appear in logging.
802
+ *
803
+ * Note that the `requestOptions` object is automatically sanitized to remove properties that
804
+ * typically contain sensitive API key and passwords. For a list of properties that are
805
+ * automatically sanitized, see the {@link sanitizeRequestOptions} method.
806
+ */
807
+ readonly requestOptionsToSanitize: string[];
808
+ userOptions: DoLookupUserOptions;
809
+ /**
810
+ * Optional middleware method for modifying {@link HttpRequestOptions} before a request is made
811
+ * via the {@link PolarityRequest.run} method or {@link PolarityRequest.runInParallel} method.
812
+ * The returned `requestOptions` object will be used for the request. This method is passed
813
+ * a copy of the original `requestOptions` object so it can be modified without side effects.
814
+ *
815
+ * This method is typically used for adding authentication (e.g., auth headers, or basic auth) to every request.
816
+ * It can also be used to add headers that are required on every request or conditionally add headers based
817
+ * on the passed in `userOptions`.
818
+ *
819
+ * This method can be set as part of the {@link PolarityRequestOptions} when creating a new instance of the
820
+ * {@link PolarityRequest} class or can be set after the fact.
821
+ *
822
+ * @param requestOptions - A copy of the request options used for the request. This object can be modified
823
+ * without side effects.
824
+ * @param userOptions - The user options passed into the `doLookup` method.
825
+ * @returns The modified request options to use for the request.
826
+ */
827
+ preprocessRequestOptions: PreprocessRequestOptions;
828
+ /**
829
+ * Optional middleware method for modifying the {@link HttpRequestResponse} after a successful request.
830
+ * The passed in {@link HttpRequestResponse} object is not a copy but can be safely modified without
831
+ * side effects. The returned `HttpRequestResponse` object will be used for the response.
832
+ *
833
+ * @param response - The HTTP response from the request.
834
+ * @param requestOptions - The request options used for the request.
835
+ * @param userOptions - The user options passed into the `doLookup` method.
836
+ */
837
+ postprocessRequestSuccess: PostprocessRequestSuccess;
838
+ /**
839
+ * Method that can be implemented to post-process the HTTP response after a failed request.
840
+ * This method is typically used to inspect the error thrown and either alter the error
841
+ * object (e.g., to change the error message property to something more specific), to ignore
842
+ * the error (by not rethrowing it), or to take a specific action based on the error (e.g.,
843
+ * in the case of a RetryRequestError you may want to retry the request or return a special
844
+ * payload to the integration front end).
845
+ *
846
+ * @param error - The error thrown during the request.
847
+ * @param requestOptions - The request options used for the request.
848
+ * @param userOptions - The user options passed into the `doLookup` method.
849
+ */
850
+ postprocessRequestFailure: PostprocessRequestFailure;
851
+ get throttlingOptions(): Bottleneck.ConstructorOptions;
852
+ set throttlingOptions(throttlingOptions: Bottleneck.ConstructorOptions);
853
+ constructor(options?: PolarityRequestOptions);
854
+ private configFieldIsValid;
855
+ /**
856
+ * Makes a single HTTP request and returns the response or throws an error
857
+ *
858
+ * @param requestOptions - request options used to make the HTTP request
859
+ * @returns The HTTP response
860
+ */
861
+ run(requestOptions: HttpRequestOptions): Promise<HttpRequestResponse> | never;
862
+ /**
863
+ * Checks whether the HTTP response is an API error and throws an ApiRequestError if it is.
864
+ *
865
+ * @param httpResponse - The HTTP response from the Postman request.
866
+ * @param requestOptions - The options used for the request.
867
+ *
868
+ * @throws {@link ApiRequestError}
869
+ * Throws an error if the response indicates an API error.
870
+ */
871
+ private maybeThrowApiRequestError;
872
+ /**
873
+ * Returns true if the `httpStatusCode` is not one of the rounded HTTP status codes
874
+ * specified in the PolarityRequest `roundedSuccessStatusCodes` property.
875
+ *
876
+ * @param httpStatusCode - A numeric HTTP Status Code
877
+ * @returns true if the provided `httpStatusCode` is an error code
878
+ */
879
+ private isHttpStatusCodeError;
880
+ /**
881
+ * Returns true indicating that the API returned an error if the `httpBody` contains
882
+ * one of the paths specified by the PolarityRequest `httpResponseErrorProperties`
883
+ * property.
884
+ *
885
+ * @param httpBody - body property from the HttpRequestResponse
886
+ * @returns `true` if the httpBody property contains properties specified in `httpResponseErrorProperties`
887
+ */
888
+ private hasHttpResponseErrorProperty;
889
+ /**
890
+ * Returns an error message based on the `httpResponseErrorMessageProperties` first. If no
891
+ * message is found, it then uses the `httpResponseErrorProperties` to attempt to find
892
+ * a suitable error message. If no message is still found, the `defaultMessage` is returned.
893
+ *
894
+ * @param httpBody - JSON Object returned by an HTTP Request
895
+ * @param defaultMessage - A default error message to use if no specific error messages are found
896
+ * @returns An error message
897
+ */
898
+ private getErrorMessageFromHttpResponse;
899
+ /**
900
+ * Given a list of `properties` which are strings representing JSON dot notation, this
901
+ * method returns the first string property found at the given JSON path
902
+ * in the given `object`.
903
+ *
904
+ * @param object - An object to find properties in
905
+ * @param properties - a list of JSON dot notation properties to look for within `object`
906
+ * @returns A string value of the property found within the given object or undefined if no value is found
907
+ */
908
+ private maybeGetStringPropertyValue;
909
+ /**
910
+ * Runs multiple requests in parallel with a limit on the maximum number of concurrent requests.
911
+ *
912
+ * When running multiple request at once it is often useful to be able to tie a specific request
913
+ * back to the entity the request is for. To support this, the `HttpRequestOptions` object accepts
914
+ * an optional `entity` property which can be assigned to the Entity the request is being made for.
915
+ * The `HttpRequestResponse` object returned by this method will include the same `entity` property
916
+ * making it easy to match the response to the entity.
917
+ *
918
+ * Alternatively, for requests that are made for multiple entities at once (e.g., a query that can
919
+ * search multiple entities at a time), the `HttpRequestOptions` object also has an `entities`
920
+ * property which accept an array of entity objects. Similar to the `entity`, the
921
+ * `entities` property will be set on the `HttpRequestResponse` object.
922
+ *
923
+ * Finally, if you are looking to pass through a custom request id you can do that using the
924
+ * `requestId` property.
925
+ *
926
+ * @param options - An array of request options for running requests in parallel.
927
+ * @returns A promise that resolves to an array of responses. If the `returnErrors` property is set to `true`
928
+ * then the response objects will have their `error` property set to the thrown error.
929
+ */
930
+ runInParallel(options: RunInParallelOptions): Promise<HttpRequestResponse[]>;
931
+ }
932
+
933
+ /**
934
+ * @public
935
+ */
936
+ export declare interface PolarityRequestOptions {
937
+ defaults?: ConfigRequestProxyOptions;
938
+ isApiError?: IsApiErrorFunction;
939
+ roundedSuccessStatusCodes?: number[];
940
+ httpResponseErrorProperties?: string[];
941
+ httpResponseErrorMessageProperties?: string[];
942
+ requestOptionsToSanitize?: string[];
943
+ preprocessRequestOptions?: PreprocessRequestOptions;
944
+ postprocessRequestSuccess?: PostprocessRequestSuccess;
945
+ postprocessRequestFailure?: PostprocessRequestFailure;
946
+ throttlingOptions?: Bottleneck.ConstructorOptions;
947
+ }
948
+
949
+ /**
950
+ * @public
951
+ */
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>>]>;
961
+
962
+ /**
963
+ * @public
964
+ */
965
+ export declare type PostprocessRequestFailure = (error: Error, requestOptions: HttpRequestOptions, userOptions: DoLookupUserOptions) => Promise<unknown> | never;
966
+
967
+ /**
968
+ * Optional middleware method for modifying the {@link HttpRequestResponse} after a successful request.
969
+ * The passed in {@link HttpRequestResponse} object is not a copy but can be safely modified without
970
+ * side effects. The returned `HttpRequestResponse` object will be used for the response.
971
+ *
972
+ * @public
973
+ */
974
+ export declare type PostprocessRequestSuccess = (response: HttpRequestResponse, requestOptions: HttpRequestOptions, userOptions: DoLookupUserOptions) => Promise<HttpRequestResponse> | never;
975
+
976
+ /**
977
+ * Optional middleware method for modifying {@link HttpRequestOptions} before a request is made
978
+ * via the {@link PolarityRequest.run} method or {@link PolarityRequest.runInParallel} method.
979
+ * The returned `requestOptions` object will be used for the request. This method is passed
980
+ * a copy of the original `requestOptions` object so it can be modified without side effects.
981
+ *
982
+ * This method is typically used for adding authentication (e.g., auth headers, or basic auth) to every request. It can also
983
+ * be used to add headers that are required on every request or conditionally add headers based
984
+ * on the passed in `userOptions`.
985
+ *
986
+ * @public
987
+ */
988
+ export declare type PreprocessRequestOptions = (requestOptions: HttpRequestOptions, userOptions: DoLookupUserOptions) => Promise<HttpRequestOptions> | never | undefined;
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
+
1040
+ /**
1041
+ * Thrown by authenticated request method for any HTTP status codes where we want to allow
1042
+ * the user to retry their lookup.
1043
+ *
1044
+ * @public
1045
+ */
1046
+ export declare class RetryRequestError extends IntegrationError {
1047
+ constructor(message: string, properties?: IntegrationErrorProperties);
1048
+ }
1049
+
1050
+ /**
1051
+ * @public
1052
+ */
1053
+ export declare type RunInParallelOptions = {
1054
+ /**
1055
+ * Array of HttpRequestOptions that will be run in parallel as specified by
1056
+ * the `maxConcurrentRequests` property.
1057
+ */
1058
+ allRequestOptions: HttpRequestOptions[];
1059
+ /**
1060
+ * Maximum number of requests to run in parallel
1061
+ *
1062
+ * @defaultValue 5
1063
+ */
1064
+ maxConcurrentRequests?: number;
1065
+ /**
1066
+ * If true, any errors thrown during the request will be returned in the response object on the `error` property
1067
+ * of the returned `HttpRequestResponse` object. If false, any errors thrown will be thrown and should be handled by
1068
+ *
1069
+ *
1070
+ * @defaultValue false
1071
+ */
1072
+ returnErrors?: boolean;
1073
+ };
1074
+
1075
+ /**
1076
+ * Sanitizes the request options by removing sensitive information
1077
+ * from the provided request options object.
1078
+ *
1079
+ * Default sanitized paths are:
1080
+ *
1081
+ * - auth.password
1082
+ * - auth.bearer
1083
+ * - body.password
1084
+ * - form.client_secret
1085
+ * - headers.authorization
1086
+ * - headers.x-api-key
1087
+ *
1088
+ * @param requestOptions - request options to sanitize
1089
+ * @param additionalPathsToSanitize - array of additional paths to sanitize in addition to the
1090
+ * default paths.
1091
+ */
1092
+ export declare function sanitizeRequestOptions(requestOptions: HttpRequestOptions, additionalPathsToSanitize?: string[]): HttpRequestOptions;
1093
+
1094
+ /**
1095
+ * @public
1096
+ */
1097
+ export declare interface SerializedIntegrationError {
1098
+ /**
1099
+ * a short, human-readable summary of the problem that SHOULD NOT change from occurrence to occurrence of
1100
+ * the problem except for purposes of localization. If omitted, the title will default to the type
1101
+ * of error (e.g., IntegrationError, or ApiRequestError)
1102
+ */
1103
+ title: string;
1104
+ /**
1105
+ * The name data property of IntegrationError.prototype is shared by all Error instances.
1106
+ * It represents the name for the type of error. For IntegrationError.prototype.name,
1107
+ * the initial value is "IntegrationError".
1108
+ */
1109
+ name: string;
1110
+ /**
1111
+ * a human-readable explanation specific to this occurrence of the problem. Like title, this field’s value can be
1112
+ * localized
1113
+ */
1114
+ detail: string;
1115
+ /**
1116
+ * An optional HTTP status code applicable to this error, expressed as a string value.
1117
+ */
1118
+ status?: string;
1119
+ /**
1120
+ * Additional details related to the error that may help the user troubleshoot the issue. If set by the user
1121
+ * via the Error constructor, the user provided value will override any automated help message set by the
1122
+ * Error class.
1123
+ */
1124
+ help?: string;
1125
+ /**
1126
+ * An optional StackTrace of the error
1127
+ */
1128
+ stack?: string;
1129
+ /**
1130
+ * An optional application-specific error code, expressed as a string value.
1131
+ */
1132
+ code?: number | string;
1133
+ /**
1134
+ * The `cause` property is used to specify the `cause` of the error. Typically,
1135
+ * this property is used to pass through a related Error instance.
1136
+ */
1137
+ cause?: Error_2;
1138
+ /**
1139
+ * Relevant for integration errors involving a network call, the `requestOptions` property
1140
+ * details the request options that resulted in the specified error. The `requestOptions` property will automatically
1141
+ * have sensitive authentication headers stripped.
1142
+ */
1143
+ requestOptions?: HttpRequestOptions;
1144
+ /**
1145
+ * an optional meta object containing non-standard meta-information about the error.
1146
+ */
1147
+ meta?: ErrorMeta;
1148
+ }
1149
+
1150
+ /**
1151
+ * Set the logger object used by the integration.
1152
+ *
1153
+ * @example
1154
+ * Example of setting the logger within the integration's startup method:
1155
+ * ```js
1156
+ * const { setLogger } = require('polarity-integration-utils/logger');
1157
+ *
1158
+ * function startup(logger){
1159
+ * setLogger(logger);
1160
+ * }
1161
+ * ```
1162
+ *
1163
+ * You can now use {@link getLogger} to get the logger object anywhere within your integration codebase.
1164
+ *
1165
+ * @public
1166
+ * @param logger - the integration logger object passed into the `startup` method
1167
+ */
1168
+ export declare const setLogger: (logger: Logger) => void;
1169
+
1170
+ /**
1171
+ * List of supported entity type values
1172
+ * @public
1173
+ */
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
+ }
1210
+
1211
+ /**
1212
+ * @public
1213
+ */
1214
+ export declare type ValidateOptionsUserOption = z.infer<typeof ValidateOptionsUserOptionSchema>;
1215
+
1216
+ /**
1217
+ * @public
1218
+ */
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>>;
1248
+
1249
+ /**
1250
+ * @public
1251
+ */
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>;
1258
+
1259
+ export { }