polarity-integration-utils 3.1.7 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dts/errors/integration-error.d.ts +11 -11
- package/dist/dts/errors/integration-error.d.ts.map +1 -1
- package/dist/dts/errors/parse-error-to-readable-json.d.ts +2 -2
- package/dist/dts/errors/parse-error-to-readable-json.d.ts.map +1 -1
- package/dist/dts/index.d.ts +1 -3
- package/dist/dts/index.d.ts.map +1 -1
- package/dist/dts/index.docs.d.ts +1 -1
- package/dist/dts/lib/errors/integration-error.d.ts +11 -11
- package/dist/dts/lib/errors/integration-error.d.ts.map +1 -1
- package/dist/dts/lib/errors/parse-error-to-readable-json.d.ts +2 -2
- package/dist/dts/lib/errors/parse-error-to-readable-json.d.ts.map +1 -1
- package/dist/dts/lib/index.d.ts +1 -3
- package/dist/dts/lib/index.d.ts.map +1 -1
- package/dist/dts/lib/index.docs.d.ts +1 -1
- package/dist/dts/lib/logging/logger.d.ts +1 -12
- package/dist/dts/lib/logging/logger.d.ts.map +1 -1
- package/dist/dts/lib/requests/polarity-request.d.ts +93 -68
- package/dist/dts/lib/requests/polarity-request.d.ts.map +1 -1
- package/dist/dts/lib/testing/enhanced-utils/create-entity.d.ts +17 -1
- package/dist/dts/lib/testing/enhanced-utils/create-entity.d.ts.map +1 -1
- package/dist/dts/lib/testing/enhanced-utils/create-mock-integration-context.d.ts +42 -2
- package/dist/dts/lib/testing/enhanced-utils/create-mock-integration-context.d.ts.map +1 -1
- package/dist/dts/lib/testing/index.d.ts +0 -3
- package/dist/dts/lib/testing/index.d.ts.map +1 -1
- package/dist/dts/lib/types.d.ts +89 -84
- package/dist/dts/lib/types.d.ts.map +1 -1
- package/dist/dts/logging/logger.d.ts +1 -12
- package/dist/dts/logging/logger.d.ts.map +1 -1
- package/dist/dts/requests/polarity-request.d.ts +93 -68
- package/dist/dts/requests/polarity-request.d.ts.map +1 -1
- package/dist/dts/testing/enhanced-utils/create-entity.d.ts +17 -1
- package/dist/dts/testing/enhanced-utils/create-entity.d.ts.map +1 -1
- package/dist/dts/testing/enhanced-utils/create-mock-integration-context.d.ts +42 -2
- package/dist/dts/testing/enhanced-utils/create-mock-integration-context.d.ts.map +1 -1
- package/dist/dts/testing/index.d.ts +0 -3
- package/dist/dts/testing/index.d.ts.map +1 -1
- package/dist/dts/tsdoc-metadata.json +1 -1
- package/dist/dts/types.d.ts +89 -84
- package/dist/dts/types.d.ts.map +1 -1
- package/dist/es/lib/errors/integration-error.js +7 -4
- package/dist/es/lib/index.docs.js +1 -1
- package/dist/es/lib/index.js +1 -5
- package/dist/es/lib/logging/logger.js +18 -7
- package/dist/es/lib/requests/polarity-request.js +103 -126
- package/dist/es/lib/testing/enhanced-utils/create-entity.js +31 -5
- package/dist/es/lib/testing/enhanced-utils/create-mock-integration-context.js +54 -27
- package/dist/es/lib/testing/index.js +0 -3
- package/dist/es/lib/types.js +2 -1
- package/dist/lib/errors/integration-error.js +7 -4
- package/dist/lib/index.docs.js +1 -1
- package/dist/lib/index.js +1 -5
- package/dist/lib/logging/logger.js +18 -7
- package/dist/lib/requests/polarity-request.js +103 -126
- package/dist/lib/testing/enhanced-utils/create-entity.js +31 -5
- package/dist/lib/testing/enhanced-utils/create-mock-integration-context.js +54 -27
- package/dist/lib/testing/index.js +0 -3
- package/dist/lib/types.js +2 -1
- package/dist/polarity-integration-utils.d.ts +264 -594
- package/package.json +8 -11
- package/dist/dts/context/cache.d.ts +0 -149
- package/dist/dts/context/cache.d.ts.map +0 -1
- package/dist/dts/context/index.d.ts +0 -3
- package/dist/dts/context/index.d.ts.map +0 -1
- package/dist/dts/context/integration-context.d.ts +0 -16
- package/dist/dts/context/integration-context.d.ts.map +0 -1
- package/dist/dts/lib/context/cache.d.ts +0 -149
- package/dist/dts/lib/context/cache.d.ts.map +0 -1
- package/dist/dts/lib/context/index.d.ts +0 -3
- package/dist/dts/lib/context/index.d.ts.map +0 -1
- package/dist/dts/lib/context/integration-context.d.ts +0 -16
- package/dist/dts/lib/context/integration-context.d.ts.map +0 -1
- package/dist/dts/lib/testing/enhanced-utils/mock-request.d.ts +0 -14
- package/dist/dts/lib/testing/enhanced-utils/mock-request.d.ts.map +0 -1
- package/dist/dts/lib/testing/enhanced-utils/validate-integration.d.ts +0 -8
- package/dist/dts/lib/testing/enhanced-utils/validate-integration.d.ts.map +0 -1
- package/dist/dts/lib/testing/test-factory/create-integration-tests.d.ts +0 -6
- package/dist/dts/lib/testing/test-factory/create-integration-tests.d.ts.map +0 -1
- package/dist/dts/lib/testing/test-factory/test-do-lookup.d.ts +0 -7
- package/dist/dts/lib/testing/test-factory/test-do-lookup.d.ts.map +0 -1
- package/dist/dts/lib/testing/test-factory/test-on-message.d.ts +0 -8
- package/dist/dts/lib/testing/test-factory/test-on-message.d.ts.map +0 -1
- package/dist/dts/lib/zod-types.d.ts +0 -278
- package/dist/dts/lib/zod-types.d.ts.map +0 -1
- package/dist/dts/testing/enhanced-utils/mock-request.d.ts +0 -14
- package/dist/dts/testing/enhanced-utils/mock-request.d.ts.map +0 -1
- package/dist/dts/testing/enhanced-utils/validate-integration.d.ts +0 -8
- package/dist/dts/testing/enhanced-utils/validate-integration.d.ts.map +0 -1
- package/dist/dts/testing/test-factory/create-integration-tests.d.ts +0 -6
- package/dist/dts/testing/test-factory/create-integration-tests.d.ts.map +0 -1
- package/dist/dts/testing/test-factory/test-do-lookup.d.ts +0 -7
- package/dist/dts/testing/test-factory/test-do-lookup.d.ts.map +0 -1
- package/dist/dts/testing/test-factory/test-on-message.d.ts +0 -8
- package/dist/dts/testing/test-factory/test-on-message.d.ts.map +0 -1
- package/dist/dts/zod-types.d.ts +0 -278
- package/dist/dts/zod-types.d.ts.map +0 -1
- package/dist/es/lib/context/cache.js +0 -2
- package/dist/es/lib/context/index.js +0 -18
- package/dist/es/lib/context/integration-context.js +0 -2
- package/dist/es/lib/testing/enhanced-utils/mock-request.js +0 -22
- package/dist/es/lib/testing/enhanced-utils/validate-integration.js +0 -159
- package/dist/es/lib/testing/test-factory/create-integration-tests.js +0 -53
- package/dist/es/lib/testing/test-factory/test-do-lookup.js +0 -24
- package/dist/es/lib/testing/test-factory/test-on-message.js +0 -24
- package/dist/es/lib/zod-types.js +0 -206
- package/dist/lib/context/cache.js +0 -2
- package/dist/lib/context/index.js +0 -18
- package/dist/lib/context/integration-context.js +0 -2
- package/dist/lib/testing/enhanced-utils/mock-request.js +0 -22
- package/dist/lib/testing/enhanced-utils/validate-integration.js +0 -159
- package/dist/lib/testing/test-factory/create-integration-tests.js +0 -53
- package/dist/lib/testing/test-factory/test-do-lookup.js +0 -24
- package/dist/lib/testing/test-factory/test-on-message.js +0 -24
- package/dist/lib/zod-types.js +0 -206
|
@@ -1,5 +1,19 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import type { DoLookupUserOptions } from '@polarityio/integration-types';
|
|
2
|
+
import type { Entity } from '@polarityio/integration-types';
|
|
3
|
+
import type { EntityType } from '@polarityio/integration-types';
|
|
4
|
+
import type { IntegrationContext } from '@polarityio/integration-types';
|
|
5
|
+
import type { Logger } from '@polarityio/integration-types';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Hook that runs after a successful HTTP response. Each hook receives the output
|
|
9
|
+
* of the previous hook, allowing the response to be modified in a chain.
|
|
10
|
+
*
|
|
11
|
+
* Typically used to extract specific fields from the response body or to
|
|
12
|
+
* transform the response into a more useful shape.
|
|
13
|
+
*
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
export declare type AfterResponseHook = (response: HttpRequestResponse, requestOptions: HttpRequestOptions, userOptions: DoLookupUserOptions) => Promise<HttpRequestResponse>;
|
|
3
17
|
|
|
4
18
|
/**
|
|
5
19
|
* API error for REST requests
|
|
@@ -20,22 +34,15 @@ export declare class AuthRequestError extends IntegrationError {
|
|
|
20
34
|
}
|
|
21
35
|
|
|
22
36
|
/**
|
|
23
|
-
*
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
/**
|
|
37
|
+
* Hook that runs before an HTTP request is made. Each hook receives the output
|
|
38
|
+
* of the previous hook, allowing request options to be modified in a chain.
|
|
39
|
+
*
|
|
40
|
+
* Typically used for adding authentication headers or conditionally modifying
|
|
41
|
+
* request options based on user options.
|
|
42
|
+
*
|
|
31
43
|
* @public
|
|
32
44
|
*/
|
|
33
|
-
export declare type
|
|
34
|
-
|
|
35
|
-
declare const ChannelSchema: z.ZodObject<{
|
|
36
|
-
channel_name: z.ZodString;
|
|
37
|
-
id: z.ZodNumber;
|
|
38
|
-
}, z.core.$strip>;
|
|
45
|
+
export declare type BeforeRequestHook = (requestOptions: HttpRequestOptions, userOptions: DoLookupUserOptions) => Promise<HttpRequestOptions>;
|
|
39
46
|
|
|
40
47
|
/**
|
|
41
48
|
* @public
|
|
@@ -51,110 +58,60 @@ export declare type ConfigRequestProxyOptions = {
|
|
|
51
58
|
};
|
|
52
59
|
|
|
53
60
|
/**
|
|
54
|
-
*
|
|
55
|
-
*/
|
|
56
|
-
export declare type DoLookupResult<TDetails = unknown> = Result<TDetails>[];
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* User options object passed into the integration's `doLookup` method.
|
|
61
|
+
* Creates a mock `Entity` for use in tests.
|
|
60
62
|
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
* ```
|
|
63
|
+
* Automatically detects whether the value is a domain or IPv4 address and sets
|
|
64
|
+
* the corresponding boolean flags. All other flags default to `false`.
|
|
65
|
+
*
|
|
66
|
+
* @param type - An `EntityType` string (e.g., `'IPv4'`, `'domain'`, `'MD5'`)
|
|
67
|
+
* @param value - The entity value string
|
|
68
|
+
* @returns A fully populated `Entity` object
|
|
68
69
|
*
|
|
69
70
|
* @example
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
* {
|
|
74
|
-
* "apiKey": "XXXXXXXXXX"
|
|
75
|
-
* }
|
|
71
|
+
* ```typescript
|
|
72
|
+
* const ip = createEntity('IPv4', '8.8.8.8');
|
|
73
|
+
* const domain = createEntity('domain', 'example.com');
|
|
76
74
|
* ```
|
|
77
|
-
* @public
|
|
78
75
|
*/
|
|
79
|
-
export declare type
|
|
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>>]>>;
|
|
76
|
+
export declare const createEntity: (type: EntityType, value: string) => Entity;
|
|
88
77
|
|
|
89
78
|
/**
|
|
90
|
-
*
|
|
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.
|
|
79
|
+
* Creates a mock `IntegrationContext`
|
|
80
|
+
* with stubbed logger, cache, and polling methods.
|
|
102
81
|
*
|
|
103
|
-
*
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
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
|
|
82
|
+
* Pass your testing framework's mock function factory to enable spy capabilities
|
|
83
|
+
* (e.g., `toHaveBeenCalledWith()`). When omitted, plain no-op stubs are used.
|
|
84
|
+
*
|
|
85
|
+
* @param createMockFn - A factory that creates mock functions (e.g., `vi.fn` or `jest.fn`)
|
|
86
|
+
* @returns A fully populated `IntegrationContext` with stubbed methods
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```typescript
|
|
90
|
+
* // Vitest
|
|
91
|
+
* const ctx = createMockIntegrationContext(vi.fn);
|
|
92
|
+
*
|
|
93
|
+
* // Jest
|
|
94
|
+
* const ctx = createMockIntegrationContext(jest.fn);
|
|
95
|
+
*
|
|
96
|
+
* // No framework — plain no-ops
|
|
97
|
+
* const ctx = createMockIntegrationContext();
|
|
98
|
+
* ```
|
|
143
99
|
*/
|
|
144
|
-
export declare
|
|
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}`>]>;
|
|
100
|
+
export declare const createMockIntegrationContext: (createMockFn?: MockFnFactory) => IntegrationContext;
|
|
147
101
|
|
|
148
102
|
/**
|
|
103
|
+
* Custom entity type definition for config.json
|
|
149
104
|
* @public
|
|
150
105
|
*/
|
|
151
|
-
declare interface
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
106
|
+
export declare interface CustomType {
|
|
107
|
+
type?: 'custom';
|
|
108
|
+
name?: string;
|
|
109
|
+
description?: string;
|
|
110
|
+
key: string;
|
|
111
|
+
regex: string;
|
|
112
|
+
editable?: boolean;
|
|
113
|
+
enabled?: boolean;
|
|
156
114
|
}
|
|
157
|
-
export { Error_2 as Error }
|
|
158
115
|
|
|
159
116
|
/**
|
|
160
117
|
* @public
|
|
@@ -180,39 +137,6 @@ export declare type ErrorMeta = {
|
|
|
180
137
|
*/
|
|
181
138
|
export declare const getLogger: () => Logger;
|
|
182
139
|
|
|
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
140
|
export declare type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'OPTIONS';
|
|
217
141
|
|
|
218
142
|
/**
|
|
@@ -346,176 +270,37 @@ export declare type HttpRequestResponse = {
|
|
|
346
270
|
[key: string]: unknown;
|
|
347
271
|
};
|
|
348
272
|
|
|
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
273
|
/**
|
|
274
|
+
* Integration config.json type
|
|
391
275
|
* @public
|
|
392
276
|
*/
|
|
393
|
-
export declare
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
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;
|
|
277
|
+
export declare interface IntegrationConfig {
|
|
278
|
+
polarityIntegrationUuid: string;
|
|
279
|
+
name: string;
|
|
280
|
+
acronym: string;
|
|
281
|
+
description?: string;
|
|
282
|
+
defaultColor?: string;
|
|
283
|
+
entityTypes?: string[];
|
|
284
|
+
dataTypes?: (string | CustomType)[];
|
|
285
|
+
customTypes?: CustomType[];
|
|
286
|
+
supportsAdditionalCustomTypes?: boolean;
|
|
287
|
+
styles?: string[];
|
|
288
|
+
block: ViewComponent;
|
|
289
|
+
summary?: ViewComponent;
|
|
290
|
+
onDemandOnly?: boolean;
|
|
291
|
+
copyOnDemand?: boolean;
|
|
292
|
+
logging?: {
|
|
293
|
+
level: 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal';
|
|
294
|
+
};
|
|
295
|
+
request?: {
|
|
296
|
+
cert?: string;
|
|
297
|
+
key?: string;
|
|
298
|
+
passphrase?: string;
|
|
299
|
+
ca?: string;
|
|
300
|
+
proxy?: string;
|
|
301
|
+
rejectUnauthorized?: boolean;
|
|
302
|
+
};
|
|
303
|
+
options?: IntegrationOption[];
|
|
519
304
|
}
|
|
520
305
|
|
|
521
306
|
/**
|
|
@@ -535,26 +320,26 @@ export declare class IntegrationError extends Error {
|
|
|
535
320
|
/**
|
|
536
321
|
* a meta object containing non-standard meta-information about the error.
|
|
537
322
|
*/
|
|
538
|
-
readonly meta
|
|
323
|
+
readonly meta?: ErrorMeta;
|
|
539
324
|
/**
|
|
540
325
|
* The HTTP status code applicable to this error, expressed as a string value.
|
|
541
326
|
*/
|
|
542
|
-
readonly status
|
|
327
|
+
readonly status?: string;
|
|
543
328
|
/**
|
|
544
329
|
* an application-specific error code, expressed as a string value.
|
|
545
330
|
*/
|
|
546
|
-
readonly code
|
|
331
|
+
readonly code?: string;
|
|
547
332
|
/**
|
|
548
333
|
* 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.
|
|
334
|
+
* this property is used to pass through a related Error instance but can be any value.
|
|
550
335
|
*/
|
|
551
|
-
readonly cause
|
|
336
|
+
readonly cause?: unknown;
|
|
552
337
|
/**
|
|
553
338
|
* Additional details related to the error that may help the user troubleshoot the issue. If set by the user
|
|
554
339
|
* via the Error constructor, the user provided value will override any automated help message set by the
|
|
555
340
|
* Error class.
|
|
556
341
|
*/
|
|
557
|
-
readonly help
|
|
342
|
+
readonly help?: string;
|
|
558
343
|
/**
|
|
559
344
|
* Relevant for integration errors involving a network call, the `requestOptions` property
|
|
560
345
|
* details the request options that resulted in the specified error. The `requestOptions` property will automatically
|
|
@@ -594,9 +379,9 @@ export declare interface IntegrationErrorProperties {
|
|
|
594
379
|
help?: string;
|
|
595
380
|
/**
|
|
596
381
|
* 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.
|
|
382
|
+
* this property is used to pass through a related Error instance but can be any value.
|
|
598
383
|
*/
|
|
599
|
-
cause?:
|
|
384
|
+
cause?: unknown;
|
|
600
385
|
/**
|
|
601
386
|
* The HTTP status code applicable to this error, expressed as a string value.
|
|
602
387
|
*/
|
|
@@ -631,6 +416,46 @@ export declare interface IntegrationErrorProperties {
|
|
|
631
416
|
meta?: MetaObject;
|
|
632
417
|
}
|
|
633
418
|
|
|
419
|
+
/**
|
|
420
|
+
* Integration option definition for config.json
|
|
421
|
+
* @public
|
|
422
|
+
*/
|
|
423
|
+
export declare type IntegrationOption = {
|
|
424
|
+
type: 'text' | 'password';
|
|
425
|
+
key: string;
|
|
426
|
+
name: string;
|
|
427
|
+
description?: string;
|
|
428
|
+
default: string | null;
|
|
429
|
+
userCanEdit?: boolean;
|
|
430
|
+
adminOnly?: boolean;
|
|
431
|
+
} | {
|
|
432
|
+
type: 'boolean';
|
|
433
|
+
key: string;
|
|
434
|
+
name: string;
|
|
435
|
+
description?: string;
|
|
436
|
+
default: boolean | null;
|
|
437
|
+
userCanEdit?: boolean;
|
|
438
|
+
adminOnly?: boolean;
|
|
439
|
+
} | {
|
|
440
|
+
type: 'number';
|
|
441
|
+
key: string;
|
|
442
|
+
name: string;
|
|
443
|
+
description?: string;
|
|
444
|
+
default: number | null;
|
|
445
|
+
userCanEdit?: boolean;
|
|
446
|
+
adminOnly?: boolean;
|
|
447
|
+
} | {
|
|
448
|
+
type: 'select';
|
|
449
|
+
key: string;
|
|
450
|
+
name: string;
|
|
451
|
+
description?: string;
|
|
452
|
+
default: SelectOptionItem | SelectOptionItem[] | string | null;
|
|
453
|
+
options: SelectOptionItem[];
|
|
454
|
+
multiple?: boolean;
|
|
455
|
+
userCanEdit: boolean;
|
|
456
|
+
adminOnly: boolean;
|
|
457
|
+
};
|
|
458
|
+
|
|
634
459
|
/**
|
|
635
460
|
* @public
|
|
636
461
|
*/
|
|
@@ -664,19 +489,14 @@ export declare class LibraryUsageError extends IntegrationError {
|
|
|
664
489
|
}
|
|
665
490
|
|
|
666
491
|
/**
|
|
492
|
+
* Minimal interface for a rate limiter compatible with PolarityRequest.
|
|
493
|
+
* The Polarity server provides a Bottleneck instance that satisfies this interface.
|
|
494
|
+
*
|
|
667
495
|
* @public
|
|
668
496
|
*/
|
|
669
|
-
declare
|
|
670
|
-
|
|
671
|
-
|
|
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 }
|
|
497
|
+
export declare interface Limiter {
|
|
498
|
+
schedule<T>(fn: (...args: unknown[]) => PromiseLike<T>, ...args: unknown[]): Promise<T>;
|
|
499
|
+
}
|
|
680
500
|
|
|
681
501
|
/**
|
|
682
502
|
* @public
|
|
@@ -685,6 +505,25 @@ export declare type MetaObject = {
|
|
|
685
505
|
[key: string]: unknown;
|
|
686
506
|
};
|
|
687
507
|
|
|
508
|
+
/**
|
|
509
|
+
* Factory function that creates mock functions. Pass `vi.fn` (Vitest)
|
|
510
|
+
* or `jest.fn` (Jest) to get spy capabilities. When omitted, plain
|
|
511
|
+
* no-op functions are used.
|
|
512
|
+
*
|
|
513
|
+
* @example
|
|
514
|
+
* ```typescript
|
|
515
|
+
* // Vitest — enables toHaveBeenCalledWith() assertions
|
|
516
|
+
* const ctx = createMockIntegrationContext(vi.fn);
|
|
517
|
+
*
|
|
518
|
+
* // Jest
|
|
519
|
+
* const ctx = createMockIntegrationContext(jest.fn);
|
|
520
|
+
*
|
|
521
|
+
* // No framework — plain no-ops
|
|
522
|
+
* const ctx = createMockIntegrationContext();
|
|
523
|
+
* ```
|
|
524
|
+
*/
|
|
525
|
+
export declare type MockFnFactory = () => (...args: any[]) => any;
|
|
526
|
+
|
|
688
527
|
/**
|
|
689
528
|
* Generic network error for REST requests.
|
|
690
529
|
* https://betterstack.com/community/guides/scaling-nodejs/nodejs-errors/#4-econnrefused
|
|
@@ -696,68 +535,43 @@ export declare class NetworkError extends IntegrationError {
|
|
|
696
535
|
}
|
|
697
536
|
|
|
698
537
|
/**
|
|
538
|
+
* Hook that runs when an API error is detected (non-success status code or error
|
|
539
|
+
* properties found in the response body). Receives the full HTTP response so the
|
|
540
|
+
* hook can inspect status codes, headers, and body.
|
|
541
|
+
*
|
|
542
|
+
* If all registered hooks return without throwing, the error is suppressed and
|
|
543
|
+
* the HTTP response is returned to the caller. To propagate or replace the error,
|
|
544
|
+
* throw from within the hook.
|
|
545
|
+
*
|
|
699
546
|
* @public
|
|
700
|
-
* @param error - Error instance to parse into a plain old javascript object
|
|
701
547
|
*/
|
|
702
|
-
export declare
|
|
548
|
+
export declare type OnApiErrorHook = (error: ApiRequestError, response: HttpRequestResponse, requestOptions: HttpRequestOptions, userOptions: DoLookupUserOptions) => Promise<void>;
|
|
703
549
|
|
|
704
550
|
/**
|
|
705
|
-
*
|
|
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
|
|
551
|
+
* Hook that runs when a network error or rate-limiting error occurs during a request.
|
|
711
552
|
*
|
|
712
|
-
*
|
|
713
|
-
*
|
|
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
|
|
553
|
+
* If all registered hooks return without throwing, the error is suppressed.
|
|
554
|
+
* To propagate or replace the error, throw from within the hook.
|
|
717
555
|
*
|
|
718
|
-
* @
|
|
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
|
-
* ```
|
|
556
|
+
* @public
|
|
740
557
|
*/
|
|
741
|
-
export declare
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
}
|
|
558
|
+
export declare type OnNetworkErrorHook = (error: NetworkError | RetryRequestError, requestOptions: HttpRequestOptions, userOptions: DoLookupUserOptions) => Promise<void>;
|
|
559
|
+
|
|
560
|
+
/**
|
|
561
|
+
* @public
|
|
562
|
+
* @param error - Error instance to parse into a plain old javascript object
|
|
563
|
+
*/
|
|
564
|
+
export declare const parseErrorToReadableJson: (error: ResponseError) => any;
|
|
749
565
|
|
|
750
566
|
/**
|
|
751
567
|
* A utility class for making HTTP requests
|
|
752
568
|
* @public
|
|
753
569
|
*/
|
|
754
570
|
export declare class PolarityRequest {
|
|
755
|
-
private bottleneckLimiter;
|
|
756
571
|
/**
|
|
757
572
|
* Instance of a Bunyan logger
|
|
758
573
|
*/
|
|
759
574
|
private logger;
|
|
760
|
-
private internalThrottlingOptions;
|
|
761
575
|
/**
|
|
762
576
|
* postman-request library request object with default values set. Used internally for
|
|
763
577
|
* making HTTP requests directly via the postman-request library
|
|
@@ -807,49 +621,20 @@ export declare class PolarityRequest {
|
|
|
807
621
|
readonly requestOptionsToSanitize: string[];
|
|
808
622
|
userOptions: DoLookupUserOptions;
|
|
809
623
|
/**
|
|
810
|
-
*
|
|
811
|
-
*
|
|
812
|
-
*
|
|
813
|
-
*
|
|
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.
|
|
624
|
+
* An optional rate limiter instance used to throttle HTTP requests.
|
|
625
|
+
* When set, all requests made via {@link PolarityRequest.run} are scheduled
|
|
626
|
+
* through this limiter. Typically provided by the Polarity server via the
|
|
627
|
+
* integration context.
|
|
836
628
|
*/
|
|
837
|
-
|
|
629
|
+
limiter: Limiter | null;
|
|
838
630
|
/**
|
|
839
|
-
*
|
|
840
|
-
*
|
|
841
|
-
*
|
|
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).
|
|
631
|
+
* Lifecycle hooks for customizing request behavior. Hooks are configured via the
|
|
632
|
+
* {@link PolarityRequestOptions.hooks} property when creating a new instance of the
|
|
633
|
+
* {@link PolarityRequest} class.
|
|
845
634
|
*
|
|
846
|
-
* @
|
|
847
|
-
* @param requestOptions - The request options used for the request.
|
|
848
|
-
* @param userOptions - The user options passed into the `doLookup` method.
|
|
635
|
+
* @see {@link PolarityRequestHooks} for hook type details.
|
|
849
636
|
*/
|
|
850
|
-
|
|
851
|
-
get throttlingOptions(): Bottleneck.ConstructorOptions;
|
|
852
|
-
set throttlingOptions(throttlingOptions: Bottleneck.ConstructorOptions);
|
|
637
|
+
readonly hooks: Required<PolarityRequestHooks>;
|
|
853
638
|
constructor(options?: PolarityRequestOptions);
|
|
854
639
|
private configFieldIsValid;
|
|
855
640
|
/**
|
|
@@ -858,17 +643,18 @@ export declare class PolarityRequest {
|
|
|
858
643
|
* @param requestOptions - request options used to make the HTTP request
|
|
859
644
|
* @returns The HTTP response
|
|
860
645
|
*/
|
|
861
|
-
run(requestOptions: HttpRequestOptions): Promise<HttpRequestResponse> | never;
|
|
646
|
+
run(requestOptions: HttpRequestOptions): Promise<HttpRequestResponse | undefined> | never;
|
|
862
647
|
/**
|
|
863
|
-
* Checks whether the HTTP response is an API error and
|
|
648
|
+
* Checks whether the HTTP response is an API error and returns an ApiRequestError if it is.
|
|
864
649
|
*
|
|
865
650
|
* @param httpResponse - The HTTP response from the Postman request.
|
|
866
651
|
* @param requestOptions - The options used for the request.
|
|
652
|
+
* @returns An ApiRequestError if the response indicates an API error, undefined otherwise.
|
|
867
653
|
*
|
|
868
|
-
* @throws {@link
|
|
869
|
-
* Throws
|
|
654
|
+
* @throws {@link LibraryUsageError}
|
|
655
|
+
* Throws if the `isApiError` function returns an invalid result.
|
|
870
656
|
*/
|
|
871
|
-
private
|
|
657
|
+
private detectApiError;
|
|
872
658
|
/**
|
|
873
659
|
* Returns true if the `httpStatusCode` is not one of the rounded HTTP status codes
|
|
874
660
|
* specified in the PolarityRequest `roundedSuccessStatusCodes` property.
|
|
@@ -924,10 +710,44 @@ export declare class PolarityRequest {
|
|
|
924
710
|
* `requestId` property.
|
|
925
711
|
*
|
|
926
712
|
* @param options - An array of request options for running requests in parallel.
|
|
927
|
-
* @returns A promise that resolves to an array of responses
|
|
928
|
-
*
|
|
713
|
+
* @returns A promise that resolves to an array of responses in the same order as the input
|
|
714
|
+
* request options. If the `returnErrors` property is set to `true`, the response objects will
|
|
715
|
+
* have their `error` property set to the thrown error. If `onNetworkError` hooks are configured
|
|
716
|
+
* and suppress an error (return without throwing), the corresponding entry will be `undefined`.
|
|
929
717
|
*/
|
|
930
|
-
runInParallel(options: RunInParallelOptions): Promise<HttpRequestResponse[]>;
|
|
718
|
+
runInParallel(options: RunInParallelOptions): Promise<(HttpRequestResponse | undefined)[]>;
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
/**
|
|
722
|
+
* Hooks for customizing the {@link PolarityRequest} lifecycle. All hook arrays
|
|
723
|
+
* execute in order. `beforeRequest` and `afterResponse` hooks chain their output,
|
|
724
|
+
* while error hooks run sequentially and can suppress errors by returning without
|
|
725
|
+
* throwing.
|
|
726
|
+
*
|
|
727
|
+
* @public
|
|
728
|
+
*/
|
|
729
|
+
export declare interface PolarityRequestHooks {
|
|
730
|
+
/**
|
|
731
|
+
* Hooks that run before each HTTP request. Each hook receives a copy of the request
|
|
732
|
+
* options and the return value is passed to the next hook (or used for the request).
|
|
733
|
+
*/
|
|
734
|
+
beforeRequest?: BeforeRequestHook[];
|
|
735
|
+
/**
|
|
736
|
+
* Hooks that run after a successful HTTP response. Each hook receives the response
|
|
737
|
+
* from the previous hook and the return value is passed to the next hook (or returned
|
|
738
|
+
* to the caller).
|
|
739
|
+
*/
|
|
740
|
+
afterResponse?: AfterResponseHook[];
|
|
741
|
+
/**
|
|
742
|
+
* Hooks that run when an API error is detected. Each hook receives the error and the
|
|
743
|
+
* full HTTP response. If all hooks return without throwing, the error is suppressed.
|
|
744
|
+
*/
|
|
745
|
+
onApiError?: OnApiErrorHook[];
|
|
746
|
+
/**
|
|
747
|
+
* Hooks that run when a network or rate-limiting error occurs. If all hooks return
|
|
748
|
+
* without throwing, the error is suppressed.
|
|
749
|
+
*/
|
|
750
|
+
onNetworkError?: OnNetworkErrorHook[];
|
|
931
751
|
}
|
|
932
752
|
|
|
933
753
|
/**
|
|
@@ -940,102 +760,19 @@ export declare class PolarityRequest {
|
|
|
940
760
|
httpResponseErrorProperties?: string[];
|
|
941
761
|
httpResponseErrorMessageProperties?: string[];
|
|
942
762
|
requestOptionsToSanitize?: string[];
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
postprocessRequestFailure?: PostprocessRequestFailure;
|
|
946
|
-
throttlingOptions?: Bottleneck.ConstructorOptions;
|
|
763
|
+
hooks?: PolarityRequestHooks;
|
|
764
|
+
limiter?: Limiter;
|
|
947
765
|
}
|
|
948
766
|
|
|
949
767
|
/**
|
|
950
768
|
* @public
|
|
951
769
|
*/
|
|
952
|
-
export declare
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
}
|
|
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>;
|
|
770
|
+
export declare interface ResponseError {
|
|
771
|
+
name: string;
|
|
772
|
+
message: string;
|
|
773
|
+
stack?: string;
|
|
774
|
+
code?: number | string;
|
|
775
|
+
}
|
|
1039
776
|
|
|
1040
777
|
/**
|
|
1041
778
|
* Thrown by authenticated request method for any HTTP status codes where we want to allow
|
|
@@ -1091,6 +828,15 @@ export declare class PolarityRequest {
|
|
|
1091
828
|
*/
|
|
1092
829
|
export declare function sanitizeRequestOptions(requestOptions: HttpRequestOptions, additionalPathsToSanitize?: string[]): HttpRequestOptions;
|
|
1093
830
|
|
|
831
|
+
/**
|
|
832
|
+
* A select option item with display label and value
|
|
833
|
+
* @public
|
|
834
|
+
*/
|
|
835
|
+
export declare interface SelectOptionItem {
|
|
836
|
+
value: string;
|
|
837
|
+
display: string;
|
|
838
|
+
}
|
|
839
|
+
|
|
1094
840
|
/**
|
|
1095
841
|
* @public
|
|
1096
842
|
*/
|
|
@@ -1132,9 +878,9 @@ export declare class PolarityRequest {
|
|
|
1132
878
|
code?: number | string;
|
|
1133
879
|
/**
|
|
1134
880
|
* 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.
|
|
881
|
+
* this property is used to pass through a related Error instance but can be any value.
|
|
1136
882
|
*/
|
|
1137
|
-
cause?:
|
|
883
|
+
cause?: unknown;
|
|
1138
884
|
/**
|
|
1139
885
|
* Relevant for integration errors involving a network call, the `requestOptions` property
|
|
1140
886
|
* details the request options that resulted in the specified error. The `requestOptions` property will automatically
|
|
@@ -1168,92 +914,16 @@ export declare class PolarityRequest {
|
|
|
1168
914
|
export declare const setLogger: (logger: Logger) => void;
|
|
1169
915
|
|
|
1170
916
|
/**
|
|
1171
|
-
*
|
|
917
|
+
* View component reference in config.json
|
|
1172
918
|
* @public
|
|
1173
919
|
*/
|
|
1174
|
-
export declare
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
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>;
|
|
920
|
+
export declare interface ViewComponent {
|
|
921
|
+
component: {
|
|
922
|
+
file: string;
|
|
923
|
+
};
|
|
924
|
+
template: {
|
|
925
|
+
file: string;
|
|
926
|
+
};
|
|
1209
927
|
}
|
|
1210
928
|
|
|
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
929
|
export { }
|