polarity-integration-utils 4.2.2 → 4.3.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.
@@ -1,5 +1,6 @@
1
1
  import { ApiRequestError, NetworkError, RetryRequestError } from '../errors';
2
- import type { Entity, DoLookupUserOptions } from '@polarityio/integration-types';
2
+ import type { Entity, DoLookupUserOptions, NetworkContext, NetworkProxy } from '@polarityio/integration-types';
3
+ export type { NetworkContext, NetworkProxy };
3
4
  /**
4
5
  * @public
5
6
  */
@@ -279,6 +280,14 @@ export interface PolarityRequestHooks {
279
280
  */
280
281
  export interface PolarityRequestOptions {
281
282
  defaults?: ConfigRequestProxyOptions;
283
+ /**
284
+ * Per-integration network configuration from `context.network`. When provided,
285
+ * proxy and TLS settings from this object override values from `defaults`.
286
+ *
287
+ * Can also be set (or updated) after construction via the {@link PolarityRequest.network}
288
+ * property to reflect per-request runtime config.
289
+ */
290
+ network?: NetworkContext;
282
291
  isApiError?: IsApiErrorFunction;
283
292
  roundedSuccessStatusCodes?: number[];
284
293
  httpResponseErrorProperties?: string[];
@@ -352,6 +361,21 @@ export declare class PolarityRequest {
352
361
  * integration context.
353
362
  */
354
363
  limiter: PolarityRequestLimiter | null;
364
+ /**
365
+ * Per-integration network configuration from `context.network`.
366
+ *
367
+ * When set, proxy and TLS settings are applied dynamically on each
368
+ * {@link PolarityRequest.run} call, overriding any static values from
369
+ * the constructor `defaults`. Set this before each `run()` call to
370
+ * reflect the latest runtime config.
371
+ *
372
+ * @example
373
+ * ```typescript
374
+ * polarityRequest.network = context.network;
375
+ * const response = await polarityRequest.run(requestOptions);
376
+ * ```
377
+ */
378
+ network: NetworkContext | null;
355
379
  /**
356
380
  * Lifecycle hooks for customizing request behavior. Hooks are configured via the
357
381
  * {@link PolarityRequestOptions.hooks} property when creating a new instance of the
@@ -1 +1 @@
1
- {"version":3,"file":"polarity-request.d.ts","sourceRoot":"","sources":["../../../lib/requests/polarity-request.ts"],"names":[],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;IACH,SAAgB,kCAAkC,EAAE,MAAM,EAAE,CAAM;IAClE;;;;;;;;;OASG;IACH,SAAgB,UAAU,EAAE,kBAAkB,CAAQ;IACtD;;;;;;;;;OASG;IACH,SAAgB,wBAAwB,EAAE,MAAM,EAAE,CAAM;IACjD,WAAW,EAAE,mBAAmB,CAAQ;IAE/C;;;;;OAKG;IACI,OAAO,EAAE,sBAAsB,GAAG,IAAI,CAAQ;IAErD;;;;;;OAMG;IACH,SAAgB,KAAK,EAAE,QAAQ,CAAC,oBAAoB,CAAC,CAKnD;gBAEU,OAAO,GAAE,sBAA2B;IAmEhD,OAAO,CAAC,kBAAkB,CACsB;IAEhD;;;;;OAKG;IACU,GAAG,CACd,cAAc,EAAE,kBAAkB,GACjC,OAAO,CAAC,mBAAmB,GAAG,SAAS,CAAC,GAAG,KAAK;IA+FnD;;;;;;;;;OASG;IACH,OAAO,CAAC,cAAc;IAoEtB;;;;;;OAMG;IACH,OAAO,CAAC,qBAAqB;IAO7B;;;;;;;OAOG;IACH,OAAO,CAAC,4BAA4B;IAIpC;;;;;;;;OAQG;IACH,OAAO,CAAC,+BAA+B;IAkBvC;;;;;;;;OAQG;IACH,OAAO,CAAC,2BAA2B;IAiBnC;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACU,aAAa,CACxB,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,CAAC,mBAAmB,GAAG,SAAS,CAAC,EAAE,CAAC;CA8ChD"}
1
+ {"version":3,"file":"polarity-request.d.ts","sourceRoot":"","sources":["../../../lib/requests/polarity-request.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,eAAe,EACf,YAAY,EACZ,iBAAiB,EAElB,MAAM,WAAW,CAAC;AAGnB,OAAO,KAAK,EACV,MAAM,EACN,mBAAmB,EACnB,cAAc,EACd,YAAY,EACb,MAAM,+BAA+B,CAAC;AAGvC,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,CAAC;AAE7C;;GAEG;AACH,MAAM,MAAM,yBA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AgB,wBAAwB,EAAE,MAAM,EAAE,CAAM;IACjD,WAAW,EAAE,mBAAmB,CAAQ;IAE/C;;;;;OAKG;IACI,OAAO,EAAE,sBAAsB,GAAG,IAAI,CAAQ;IAErD;;;;;;;;;;;;;OAaG;IACI,OAAO,EAAE,cAAc,GAAG,IAAI,CAAQ;IAE7C;;;;;;OAMG;IACH,SAAgB,KAAK,EAAE,QAAQ,CAAC,oBAAoB,CAAC,CAKnD;gBAEU,OAAO,GAAE,sBAA2B;IAuEhD,OAAO,CAAC,kBAAkB,CACsB;IAEhD;;;;;OAKG;IACU,GAAG,CACd,cAAc,EAAE,kBAAkB,GACjC,OAAO,CAAC,mBAAmB,GAAG,SAAS,CAAC,GAAG,KAAK;IA+GnD;;;;;;;;;OASG;IACH,OAAO,CAAC,cAAc;IAoEtB;;;;;;OAMG;IACH,OAAO,CAAC,qBAAqB;IAO7B;;;;;;;OAOG;IACH,OAAO,CAAC,4BAA4B;IAIpC;;;;;;;;OAQG;IACH,OAAO,CAAC,+BAA+B;IAkBvC;;;;;;;;OAQG;IACH,OAAO,CAAC,2BAA2B;IAiBnC;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACU,aAAa,CACxB,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,CAAC,mBAAmB,GAAG,SAAS,CAAC,EAAE,CAAC;CA8ChD"}
@@ -1 +1 @@
1
- {"version":3,"file":"create-mock-integration-context.d.ts","sourceRoot":"","sources":["../../../../lib/testing/enhanced-utils/create-mock-integration-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAExE;;;;;;;;;;;;;;;;;GAiBG;AAEH,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC;AAI1D;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,4BAA4B,GACvC,eAAc,aAAoB,KACjC,kBAuGF,CAAC"}
1
+ {"version":3,"file":"create-mock-integration-context.d.ts","sourceRoot":"","sources":["../../../../lib/testing/enhanced-utils/create-mock-integration-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAExE;;;;;;;;;;;;;;;;;GAiBG;AAEH,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC;AAI1D;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,4BAA4B,GACvC,eAAc,aAAoB,KACjC,kBA0GF,CAAC"}
@@ -78,6 +78,21 @@ class PolarityRequest {
78
78
  * integration context.
79
79
  */
80
80
  limiter = null;
81
+ /**
82
+ * Per-integration network configuration from `context.network`.
83
+ *
84
+ * When set, proxy and TLS settings are applied dynamically on each
85
+ * {@link PolarityRequest.run} call, overriding any static values from
86
+ * the constructor `defaults`. Set this before each `run()` call to
87
+ * reflect the latest runtime config.
88
+ *
89
+ * @example
90
+ * ```typescript
91
+ * polarityRequest.network = context.network;
92
+ * const response = await polarityRequest.run(requestOptions);
93
+ * ```
94
+ */
95
+ network = null;
81
96
  /**
82
97
  * Lifecycle hooks for customizing request behavior. Hooks are configured via the
83
98
  * {@link PolarityRequestOptions.hooks} property when creating a new instance of the
@@ -133,6 +148,9 @@ class PolarityRequest {
133
148
  if (options.limiter) {
134
149
  this.limiter = options.limiter;
135
150
  }
151
+ if (options.network) {
152
+ this.network = options.network;
153
+ }
136
154
  const defaultRequestOptions = {
137
155
  ...(this.configFieldIsValid(ca) && { ca: fs_1.default.readFileSync(ca) }),
138
156
  ...(this.configFieldIsValid(cert) && { cert: fs_1.default.readFileSync(cert) }),
@@ -164,6 +182,21 @@ class PolarityRequest {
164
182
  }
165
183
  processedOptions = hookResult;
166
184
  }
185
+ // Apply runtime network settings (overrides defaults and hook mutations)
186
+ if (this.network) {
187
+ const url = (processedOptions.url || '').trim().toLowerCase();
188
+ const isHttps = url.startsWith('https://') || !url.startsWith('http://');
189
+ const proxy = isHttps
190
+ ? (this.network.proxy?.https ?? this.network.proxy?.http)
191
+ : (this.network.proxy?.http ?? this.network.proxy?.https);
192
+ if (proxy) {
193
+ processedOptions.proxy = proxy;
194
+ }
195
+ if (this.network.proxy?.noProxy) {
196
+ processedOptions.noProxyHost = this.network.proxy.noProxy;
197
+ }
198
+ processedOptions.rejectUnauthorized = this.network.rejectUnauthorized;
199
+ }
167
200
  let httpResponse;
168
201
  try {
169
202
  httpResponse = await (this.limiter
@@ -111,7 +111,10 @@ const createMockIntegrationContext = (createMockFn = noOp) => {
111
111
  : () => ({ schedule: scheduleImpl }))
112
112
  },
113
113
  startPolling: createMockFn(),
114
- stopPolling: createMockFn()
114
+ stopPolling: createMockFn(),
115
+ network: {
116
+ rejectUnauthorized: true
117
+ }
115
118
  };
116
119
  };
117
120
  exports.createMockIntegrationContext = createMockIntegrationContext;
@@ -78,6 +78,21 @@ class PolarityRequest {
78
78
  * integration context.
79
79
  */
80
80
  limiter = null;
81
+ /**
82
+ * Per-integration network configuration from `context.network`.
83
+ *
84
+ * When set, proxy and TLS settings are applied dynamically on each
85
+ * {@link PolarityRequest.run} call, overriding any static values from
86
+ * the constructor `defaults`. Set this before each `run()` call to
87
+ * reflect the latest runtime config.
88
+ *
89
+ * @example
90
+ * ```typescript
91
+ * polarityRequest.network = context.network;
92
+ * const response = await polarityRequest.run(requestOptions);
93
+ * ```
94
+ */
95
+ network = null;
81
96
  /**
82
97
  * Lifecycle hooks for customizing request behavior. Hooks are configured via the
83
98
  * {@link PolarityRequestOptions.hooks} property when creating a new instance of the
@@ -133,6 +148,9 @@ class PolarityRequest {
133
148
  if (options.limiter) {
134
149
  this.limiter = options.limiter;
135
150
  }
151
+ if (options.network) {
152
+ this.network = options.network;
153
+ }
136
154
  const defaultRequestOptions = {
137
155
  ...(this.configFieldIsValid(ca) && { ca: fs_1.default.readFileSync(ca) }),
138
156
  ...(this.configFieldIsValid(cert) && { cert: fs_1.default.readFileSync(cert) }),
@@ -164,6 +182,21 @@ class PolarityRequest {
164
182
  }
165
183
  processedOptions = hookResult;
166
184
  }
185
+ // Apply runtime network settings (overrides defaults and hook mutations)
186
+ if (this.network) {
187
+ const url = (processedOptions.url || '').trim().toLowerCase();
188
+ const isHttps = url.startsWith('https://') || !url.startsWith('http://');
189
+ const proxy = isHttps
190
+ ? (this.network.proxy?.https ?? this.network.proxy?.http)
191
+ : (this.network.proxy?.http ?? this.network.proxy?.https);
192
+ if (proxy) {
193
+ processedOptions.proxy = proxy;
194
+ }
195
+ if (this.network.proxy?.noProxy) {
196
+ processedOptions.noProxyHost = this.network.proxy.noProxy;
197
+ }
198
+ processedOptions.rejectUnauthorized = this.network.rejectUnauthorized;
199
+ }
167
200
  let httpResponse;
168
201
  try {
169
202
  httpResponse = await (this.limiter
@@ -111,7 +111,10 @@ const createMockIntegrationContext = (createMockFn = noOp) => {
111
111
  : () => ({ schedule: scheduleImpl }))
112
112
  },
113
113
  startPolling: createMockFn(),
114
- stopPolling: createMockFn()
114
+ stopPolling: createMockFn(),
115
+ network: {
116
+ rejectUnauthorized: true
117
+ }
115
118
  };
116
119
  };
117
120
  exports.createMockIntegrationContext = createMockIntegrationContext;
@@ -3,6 +3,8 @@ import type { Entity } from '@polarityio/integration-types';
3
3
  import type { EntityType } from '@polarityio/integration-types';
4
4
  import type { IntegrationContext } from '@polarityio/integration-types';
5
5
  import type { Logger } from '@polarityio/integration-types';
6
+ import type { NetworkContext } from '@polarityio/integration-types';
7
+ import type { NetworkProxy } from '@polarityio/integration-types';
6
8
 
7
9
  /**
8
10
  * Hook that runs after a successful HTTP response. Each hook receives the output
@@ -551,6 +553,8 @@ export declare type ConfigRequestProxyOptions = {
551
553
  */
552
554
  export declare type MockFnFactory = () => (...args: any[]) => any;
553
555
 
556
+ export { NetworkContext }
557
+
554
558
  /**
555
559
  * Generic network error for REST requests.
556
560
  * https://betterstack.com/community/guides/scaling-nodejs/nodejs-errors/#4-econnrefused
@@ -561,6 +565,8 @@ export declare type ConfigRequestProxyOptions = {
561
565
  constructor(message: string, properties?: IntegrationErrorProperties);
562
566
  }
563
567
 
568
+ export { NetworkProxy }
569
+
564
570
  /**
565
571
  * Hook that runs when an API error is detected (non-success status code or error
566
572
  * properties found in the response body). Receives the full HTTP response so the
@@ -657,6 +663,21 @@ export declare type ConfigRequestProxyOptions = {
657
663
  * integration context.
658
664
  */
659
665
  limiter: PolarityRequestLimiter | null;
666
+ /**
667
+ * Per-integration network configuration from `context.network`.
668
+ *
669
+ * When set, proxy and TLS settings are applied dynamically on each
670
+ * {@link PolarityRequest.run} call, overriding any static values from
671
+ * the constructor `defaults`. Set this before each `run()` call to
672
+ * reflect the latest runtime config.
673
+ *
674
+ * @example
675
+ * ```typescript
676
+ * polarityRequest.network = context.network;
677
+ * const response = await polarityRequest.run(requestOptions);
678
+ * ```
679
+ */
680
+ network: NetworkContext | null;
660
681
  /**
661
682
  * Lifecycle hooks for customizing request behavior. Hooks are configured via the
662
683
  * {@link PolarityRequestOptions.hooks} property when creating a new instance of the
@@ -798,6 +819,14 @@ export declare type ConfigRequestProxyOptions = {
798
819
  */
799
820
  export declare interface PolarityRequestOptions {
800
821
  defaults?: ConfigRequestProxyOptions;
822
+ /**
823
+ * Per-integration network configuration from `context.network`. When provided,
824
+ * proxy and TLS settings from this object override values from `defaults`.
825
+ *
826
+ * Can also be set (or updated) after construction via the {@link PolarityRequest.network}
827
+ * property to reflect per-request runtime config.
828
+ */
829
+ network?: NetworkContext;
801
830
  isApiError?: IsApiErrorFunction;
802
831
  roundedSuccessStatusCodes?: number[];
803
832
  httpResponseErrorProperties?: string[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "polarity-integration-utils",
3
- "version": "4.2.2",
3
+ "version": "4.3.0",
4
4
  "description": "A utility library for building Polarity Integrations",
5
5
  "files": [
6
6
  "dist"
@@ -86,7 +86,7 @@
86
86
  "devDependencies": {
87
87
  "@eslint/js": "^9.39.4",
88
88
  "@microsoft/api-extractor": "^7.57.7",
89
- "@polarityio/integration-types": "^1.2.1",
89
+ "@polarityio/integration-types": "^2.0.0",
90
90
  "@types/jest": "^30.0.0",
91
91
  "@types/lodash": "^4.17.24",
92
92
  "@types/node": "^20.14.8",
@@ -108,7 +108,7 @@
108
108
  "postman-request": "^2.88.1-postman.48"
109
109
  },
110
110
  "peerDependencies": {
111
- "@polarityio/integration-types": "^1.2.1"
111
+ "@polarityio/integration-types": "^2.0.0"
112
112
  },
113
113
  "sideEffects": false,
114
114
  "overrides": {