@polarityio/integration-types 1.2.1 → 2.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/context.d.ts +133 -0
- package/dist/index.d.ts +1 -1
- package/package.json +1 -1
package/dist/context.d.ts
CHANGED
|
@@ -118,6 +118,137 @@ export interface PolarityCache {
|
|
|
118
118
|
integration: IntegrationCache;
|
|
119
119
|
user: UserCache;
|
|
120
120
|
}
|
|
121
|
+
/**
|
|
122
|
+
* Proxy configuration for per-integration HTTP proxy overrides (tier 1).
|
|
123
|
+
*
|
|
124
|
+
* Present only when the Polarity admin has configured a per-integration
|
|
125
|
+
* proxy override. Global proxy settings (tier 2) and host environment
|
|
126
|
+
* proxy variables (tier 3) are **not** surfaced here — they are injected
|
|
127
|
+
* into the worker subprocess environment and picked up by HTTP clients
|
|
128
|
+
* automatically.
|
|
129
|
+
*
|
|
130
|
+
* @example Resolving the proxy URL for a request
|
|
131
|
+
* ```typescript
|
|
132
|
+
* const proxyUrl = context.network.proxy?.https ?? context.network.proxy?.http;
|
|
133
|
+
* ```
|
|
134
|
+
*/
|
|
135
|
+
export interface NetworkProxy {
|
|
136
|
+
/**
|
|
137
|
+
* HTTP proxy URL for plain-text requests.
|
|
138
|
+
* Omitted (not `null`) when unset.
|
|
139
|
+
*
|
|
140
|
+
* @example "http://user:pass@proxy.corp:8080"
|
|
141
|
+
*/
|
|
142
|
+
http?: string;
|
|
143
|
+
/**
|
|
144
|
+
* HTTPS proxy URL for TLS requests.
|
|
145
|
+
* Omitted (not `null`) when unset. Today this is typically the same
|
|
146
|
+
* URL as `http`; both fields exist for future per-scheme support.
|
|
147
|
+
*
|
|
148
|
+
* @example "http://user:pass@proxy.corp:8080"
|
|
149
|
+
*/
|
|
150
|
+
https?: string;
|
|
151
|
+
/**
|
|
152
|
+
* Comma- or whitespace-separated list of hosts/domains that bypass
|
|
153
|
+
* the per-integration proxy.
|
|
154
|
+
*
|
|
155
|
+
* - Omitted when unset (no explicit bypass list configured).
|
|
156
|
+
* - `null` only when the admin explicitly set the bypass list to empty
|
|
157
|
+
* (a valid `NO_PROXY` value meaning "no exceptions — proxy everything").
|
|
158
|
+
*
|
|
159
|
+
* Supports patterns: exact host, `.suffix` domain matching, and `*` wildcard.
|
|
160
|
+
*
|
|
161
|
+
* @example "localhost,.internal,*.corp"
|
|
162
|
+
*/
|
|
163
|
+
noProxy?: string | null;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Per-integration network configuration provided on every dispatch via
|
|
167
|
+
* `context.network`.
|
|
168
|
+
*
|
|
169
|
+
* Contains **tier-1** (per-integration) TLS and proxy overrides configured
|
|
170
|
+
* by the Polarity admin. Global and host proxy settings are handled
|
|
171
|
+
* transparently via the worker environment and do not appear here.
|
|
172
|
+
*
|
|
173
|
+
* ### Precedence
|
|
174
|
+
*
|
|
175
|
+
* 1. **Tier 1 — Per-integration** → surfaces on `context.network`
|
|
176
|
+
* 2. **Tier 2 — Global Proxy Settings** → worker env (`HTTPS_PROXY`, etc.)
|
|
177
|
+
* 3. **Tier 3 — Host env** → inherited by worker subprocess
|
|
178
|
+
*
|
|
179
|
+
* ### Key Rules
|
|
180
|
+
*
|
|
181
|
+
* - Do **not** cache HTTP clients across dispatches — settings may change
|
|
182
|
+
* between dispatches when an admin updates the configuration.
|
|
183
|
+
* - Do **not** set `process.env.HTTP_PROXY` or
|
|
184
|
+
* `process.env.NODE_TLS_REJECT_UNAUTHORIZED` at runtime — this is racy
|
|
185
|
+
* on shared workers and leaks settings between integrations.
|
|
186
|
+
* - When `proxy` is absent, do nothing — the worker env carries
|
|
187
|
+
* tier 2/3 and most HTTP clients pick it up natively.
|
|
188
|
+
*
|
|
189
|
+
* @example Basic usage with any HTTP client
|
|
190
|
+
* ```typescript
|
|
191
|
+
* async function doLookup(entities, options, context) {
|
|
192
|
+
* const proxyUrl = context.network.proxy?.https ?? context.network.proxy?.http;
|
|
193
|
+
* const rejectUnauthorized = context.network.rejectUnauthorized !== false;
|
|
194
|
+
* // Wire proxyUrl and rejectUnauthorized into your HTTP client
|
|
195
|
+
* }
|
|
196
|
+
* ```
|
|
197
|
+
*
|
|
198
|
+
* @example Usage with postman-request
|
|
199
|
+
* ```typescript
|
|
200
|
+
* async function doLookup(entities, options, context) {
|
|
201
|
+
* const proxy = context.network.proxy?.https ?? context.network.proxy?.http;
|
|
202
|
+
* const client = request.defaults({
|
|
203
|
+
* ...(proxy && { proxy }),
|
|
204
|
+
* ...(context.network.rejectUnauthorized === false && {
|
|
205
|
+
* strictSSL: false,
|
|
206
|
+
* rejectUnauthorized: false,
|
|
207
|
+
* }),
|
|
208
|
+
* });
|
|
209
|
+
* }
|
|
210
|
+
* ```
|
|
211
|
+
*
|
|
212
|
+
* @example Usage with axios
|
|
213
|
+
* ```typescript
|
|
214
|
+
* async function doLookup(entities, options, context) {
|
|
215
|
+
* const proxyUrl = context.network.proxy?.https ?? context.network.proxy?.http;
|
|
216
|
+
* const config: AxiosRequestConfig = {};
|
|
217
|
+
* if (proxyUrl) {
|
|
218
|
+
* const u = new URL(proxyUrl);
|
|
219
|
+
* config.proxy = {
|
|
220
|
+
* protocol: u.protocol.replace(':', ''),
|
|
221
|
+
* host: u.hostname,
|
|
222
|
+
* port: Number(u.port) || (u.protocol === 'https:' ? 443 : 80),
|
|
223
|
+
* ...(u.username && { auth: { username: u.username, password: u.password } }),
|
|
224
|
+
* };
|
|
225
|
+
* }
|
|
226
|
+
* if (context.network.rejectUnauthorized === false) {
|
|
227
|
+
* config.httpsAgent = new https.Agent({ rejectUnauthorized: false });
|
|
228
|
+
* }
|
|
229
|
+
* }
|
|
230
|
+
* ```
|
|
231
|
+
*/
|
|
232
|
+
export interface NetworkContext {
|
|
233
|
+
/**
|
|
234
|
+
* Per-integration proxy override (tier 1).
|
|
235
|
+
*
|
|
236
|
+
* **Omitted entirely** when no per-integration proxy is configured.
|
|
237
|
+
* When absent, HTTP clients should use their default behavior
|
|
238
|
+
* (which will pick up tier 2/3 from the worker environment).
|
|
239
|
+
*/
|
|
240
|
+
proxy?: NetworkProxy;
|
|
241
|
+
/**
|
|
242
|
+
* Whether outbound TLS certificates should be verified.
|
|
243
|
+
*
|
|
244
|
+
* - `true` (default) — enforce certificate validation.
|
|
245
|
+
* - `false` — skip TLS certificate verification. Corresponds to the
|
|
246
|
+
* integration's "Allow Unauthorized TLS Certificates" admin setting.
|
|
247
|
+
*
|
|
248
|
+
* **Always present** — TLS strictness is meaningful regardless of proxy config.
|
|
249
|
+
*/
|
|
250
|
+
rejectUnauthorized: boolean;
|
|
251
|
+
}
|
|
121
252
|
/**
|
|
122
253
|
* Integration context provided to integration functions (`doLookup`, `onMessage`,
|
|
123
254
|
* `onDetails`, `validateOptions`).
|
|
@@ -128,6 +259,8 @@ export interface IntegrationContext {
|
|
|
128
259
|
userId: number;
|
|
129
260
|
logger: Logger;
|
|
130
261
|
limiter: Limiter;
|
|
262
|
+
/** Per-integration network (TLS/proxy) configuration provided by the runtime on every dispatch. */
|
|
263
|
+
network: NetworkContext;
|
|
131
264
|
startPolling: (pollName: string) => void;
|
|
132
265
|
stopPolling: (pollName: string) => void;
|
|
133
266
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export type { Channel, StandardEntityType, EntityType, EntityTypeIdentifier, EntityPosition, OnDemandRequestContext, ScreenChangeRequestContext, RequestContext, Entity } from './entity';
|
|
2
2
|
export type { SelectTypeOptionValue, PossibleUserOptionValue, DoLookupUserOptions, ValidateOptionsUserOption, ValidateOptionsUserOptions, ValidationError } from './user-options';
|
|
3
3
|
export type { LookupResult, DoLookupResult } from './result';
|
|
4
|
-
export type { CacheOptions, GlobalCache, IntegrationCache, UserCache, PolarityCache, IntegrationContext } from './context';
|
|
4
|
+
export type { CacheOptions, GlobalCache, IntegrationCache, UserCache, PolarityCache, NetworkProxy, NetworkContext, IntegrationContext } from './context';
|
|
5
5
|
export type { ThrottleStrategy, ScheduleOptions, LimiterCounts, ThrottleSettings, ScopedLimiter, Limiter } from './limiter';
|
|
6
6
|
export type { Logger } from './logger';
|
|
7
7
|
export type { Integration } from './integration';
|