polarity-integration-utils 4.1.0 → 4.2.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/cache/create-cache-key.d.ts +23 -0
- package/dist/dts/cache/create-cache-key.d.ts.map +1 -0
- package/dist/dts/cache/index.d.ts +2 -0
- package/dist/dts/cache/index.d.ts.map +1 -0
- package/dist/dts/errors/integration-error.d.ts +1 -0
- package/dist/dts/errors/integration-error.d.ts.map +1 -1
- package/dist/dts/errors/parse-error-to-readable-json.d.ts +2 -0
- package/dist/dts/errors/parse-error-to-readable-json.d.ts.map +1 -1
- package/dist/dts/index.d.ts +3 -1
- package/dist/dts/index.d.ts.map +1 -1
- package/dist/dts/index.docs.d.ts +1 -0
- package/dist/dts/index.docs.d.ts.map +1 -1
- package/dist/dts/logging/logger.d.ts +2 -0
- package/dist/dts/logging/logger.d.ts.map +1 -1
- package/dist/dts/requests/polarity-request.d.ts +1 -0
- package/dist/dts/requests/polarity-request.d.ts.map +1 -1
- package/dist/dts/requests/sanitize-request-options.d.ts +2 -0
- package/dist/dts/requests/sanitize-request-options.d.ts.map +1 -1
- package/dist/dts/testing/enhanced-utils/create-entity.d.ts +3 -0
- 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 +4 -0
- package/dist/dts/testing/enhanced-utils/create-mock-integration-context.d.ts.map +1 -1
- package/dist/es/cache/create-cache-key.js +56 -0
- package/dist/es/cache/index.js +5 -0
- package/dist/es/{lib/errors → errors}/parse-error-to-readable-json.js +2 -0
- package/dist/es/{lib/index.docs.js → index.docs.js} +1 -0
- package/dist/es/{lib/index.js → index.js} +4 -1
- package/dist/es/{lib/logging → logging}/logger.js +2 -0
- package/dist/es/{lib/requests → requests}/polarity-request.js +1 -0
- package/dist/es/{lib/requests → requests}/sanitize-request-options.js +2 -0
- package/dist/es/{lib/testing → testing}/enhanced-utils/create-entity.js +3 -0
- package/dist/es/{lib/testing → testing}/enhanced-utils/create-mock-integration-context.js +3 -0
- package/dist/lib/cache/create-cache-key.js +56 -0
- package/dist/lib/cache/index.js +5 -0
- package/dist/lib/errors/parse-error-to-readable-json.js +2 -0
- package/dist/lib/index.docs.js +1 -0
- package/dist/lib/index.js +4 -1
- package/dist/lib/logging/logger.js +2 -0
- package/dist/lib/requests/polarity-request.js +1 -0
- package/dist/lib/requests/sanitize-request-options.js +2 -0
- package/dist/lib/testing/enhanced-utils/create-entity.js +3 -0
- package/dist/lib/testing/enhanced-utils/create-mock-integration-context.js +3 -0
- package/dist/polarity-integration-utils.d.ts +880 -842
- package/package.json +7 -2
- package/dist/dts/lib/errors/api-request-error.d.ts +0 -10
- package/dist/dts/lib/errors/api-request-error.d.ts.map +0 -1
- package/dist/dts/lib/errors/auth-request-error.d.ts +0 -10
- package/dist/dts/lib/errors/auth-request-error.d.ts.map +0 -1
- package/dist/dts/lib/errors/index.d.ts +0 -8
- package/dist/dts/lib/errors/index.d.ts.map +0 -1
- package/dist/dts/lib/errors/integration-error.d.ts +0 -189
- package/dist/dts/lib/errors/integration-error.d.ts.map +0 -1
- package/dist/dts/lib/errors/library-usage-error.d.ts +0 -12
- package/dist/dts/lib/errors/library-usage-error.d.ts.map +0 -1
- package/dist/dts/lib/errors/network-error.d.ts +0 -11
- package/dist/dts/lib/errors/network-error.d.ts.map +0 -1
- package/dist/dts/lib/errors/parse-error-to-readable-json.d.ts +0 -7
- package/dist/dts/lib/errors/parse-error-to-readable-json.d.ts.map +0 -1
- package/dist/dts/lib/errors/retry-request-error.d.ts +0 -11
- package/dist/dts/lib/errors/retry-request-error.d.ts.map +0 -1
- package/dist/dts/lib/index.d.ts +0 -9
- package/dist/dts/lib/index.d.ts.map +0 -1
- package/dist/dts/lib/index.docs.d.ts +0 -14
- package/dist/dts/lib/index.docs.d.ts.map +0 -1
- package/dist/dts/lib/internal/helpers/parallel-limit.d.ts +0 -9
- package/dist/dts/lib/internal/helpers/parallel-limit.d.ts.map +0 -1
- package/dist/dts/lib/internal/helpers/sanitize-object.d.ts +0 -11
- package/dist/dts/lib/internal/helpers/sanitize-object.d.ts.map +0 -1
- package/dist/dts/lib/logging/index.d.ts +0 -2
- package/dist/dts/lib/logging/index.d.ts.map +0 -1
- package/dist/dts/lib/logging/logger.d.ts +0 -38
- package/dist/dts/lib/logging/logger.d.ts.map +0 -1
- package/dist/dts/lib/requests/index.d.ts +0 -3
- package/dist/dts/lib/requests/index.d.ts.map +0 -1
- package/dist/dts/lib/requests/polarity-request.d.ts +0 -436
- package/dist/dts/lib/requests/polarity-request.d.ts.map +0 -1
- package/dist/dts/lib/requests/sanitize-request-options.d.ts +0 -20
- package/dist/dts/lib/requests/sanitize-request-options.d.ts.map +0 -1
- package/dist/dts/lib/testing/enhanced-utils/create-entity.d.ts +0 -19
- package/dist/dts/lib/testing/enhanced-utils/create-entity.d.ts.map +0 -1
- package/dist/dts/lib/testing/enhanced-utils/create-mock-integration-context.d.ts +0 -43
- package/dist/dts/lib/testing/enhanced-utils/create-mock-integration-context.d.ts.map +0 -1
- package/dist/dts/lib/testing/index.d.ts +0 -3
- package/dist/dts/lib/testing/index.d.ts.map +0 -1
- package/dist/dts/lib/types.d.ts +0 -105
- package/dist/dts/lib/types.d.ts.map +0 -1
- /package/dist/es/{lib/errors → errors}/api-request-error.js +0 -0
- /package/dist/es/{lib/errors → errors}/auth-request-error.js +0 -0
- /package/dist/es/{lib/errors → errors}/index.js +0 -0
- /package/dist/es/{lib/errors → errors}/integration-error.js +0 -0
- /package/dist/es/{lib/errors → errors}/library-usage-error.js +0 -0
- /package/dist/es/{lib/errors → errors}/network-error.js +0 -0
- /package/dist/es/{lib/errors → errors}/retry-request-error.js +0 -0
- /package/dist/es/{lib/internal → internal}/helpers/parallel-limit.js +0 -0
- /package/dist/es/{lib/internal → internal}/helpers/sanitize-object.js +0 -0
- /package/dist/es/{lib/logging → logging}/index.js +0 -0
- /package/dist/es/{lib/requests → requests}/index.js +0 -0
- /package/dist/es/{lib/testing → testing}/index.js +0 -0
- /package/dist/es/{lib/types.js → types.js} +0 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a cache-safe key by hashing the input values with SHA-256 and
|
|
3
|
+
* prepending a descriptive prefix.
|
|
4
|
+
*
|
|
5
|
+
* Use this to derive cache keys from dynamic or sensitive data (entity values,
|
|
6
|
+
* credentials, etc.) that may contain characters outside the allowed set.
|
|
7
|
+
*
|
|
8
|
+
* @param prefix - A short descriptive label using only letters, digits, dots,
|
|
9
|
+
* underscores, and hyphens (must match `/^[a-zA-Z0-9._-]+$/`).
|
|
10
|
+
* @param value - First value to hash (required).
|
|
11
|
+
* @param values - Additional values to hash (e.g., further credentials or identifiers).
|
|
12
|
+
* @returns A key in the form `prefix_<64-char hex hash>`.
|
|
13
|
+
*
|
|
14
|
+
* @throws {@link LibraryUsageError}
|
|
15
|
+
* If `prefix` or `value` is not a string, if `prefix` is empty or contains
|
|
16
|
+
* invalid characters, if any additional value is not a string, or if the
|
|
17
|
+
* resulting key would exceed 250 characters.
|
|
18
|
+
*
|
|
19
|
+
* @group Utilities
|
|
20
|
+
* @public
|
|
21
|
+
*/
|
|
22
|
+
export declare function createCacheKey(prefix: string, value: string, ...values: string[]): string;
|
|
23
|
+
//# sourceMappingURL=create-cache-key.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-cache-key.d.ts","sourceRoot":"","sources":["../../../lib/cache/create-cache-key.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAqCzF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/cache/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integration-error.d.ts","sourceRoot":"","sources":["../../../lib/errors/integration-error.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAGvE
|
|
1
|
+
{"version":3,"file":"integration-error.d.ts","sourceRoot":"","sources":["../../../lib/errors/integration-error.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAGvE;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG;IACtB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC;CAClC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG;IAEvB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;;;;;;;;;;;OAcG;IACH,cAAc,CAAC,EAAE,kBAAkB,CAAC;IACpC;;OAEG;IACH,wBAAwB,CAAC,EAAE,MAAM,EAAE,CAAC;IACpC;;OAEG;IACH,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB;AAED;;GAEG;AACH,MAA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ources":["../../../lib/errors/parse-error-to-readable-json.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD
|
|
1
|
+
{"version":3,"file":"parse-error-to-readable-json.d.ts","sourceRoot":"","sources":["../../../lib/errors/parse-error-to-readable-json.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,GAAI,OAAO,aAAa,QACS,CAAC"}
|
package/dist/dts/index.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import * as errors from './errors';
|
|
2
2
|
import * as requests from './requests';
|
|
3
3
|
import * as logging from './logging';
|
|
4
|
+
import * as cache from './cache';
|
|
4
5
|
export * from './types';
|
|
5
6
|
export * from './errors';
|
|
6
7
|
export * from './requests';
|
|
7
8
|
export * from './logging';
|
|
8
|
-
export
|
|
9
|
+
export * from './cache';
|
|
10
|
+
export { errors, requests, logging, cache };
|
|
9
11
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/dts/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AACnC,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AACnC,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AACrC,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AAEjC,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AAExB,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC"}
|
package/dist/dts/index.docs.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.docs.d.ts","sourceRoot":"","sources":["../../lib/index.docs.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.docs.d.ts","sourceRoot":"","sources":["../../lib/index.docs.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC"}
|
|
@@ -14,6 +14,7 @@ import type { Logger } from '@polarityio/integration-types';
|
|
|
14
14
|
*
|
|
15
15
|
* You can now use {@link getLogger} to get the logger object anywhere within your integration codebase.
|
|
16
16
|
*
|
|
17
|
+
* @group Logging
|
|
17
18
|
* @public
|
|
18
19
|
* @param logger - the integration logger object passed into the `startup` method
|
|
19
20
|
*/
|
|
@@ -30,6 +31,7 @@ declare const setLogger: (logger: Logger) => void;
|
|
|
30
31
|
* logger.trace('this is a trace message');
|
|
31
32
|
* ```
|
|
32
33
|
*
|
|
34
|
+
* @group Logging
|
|
33
35
|
* @public
|
|
34
36
|
* @returns the integration's logger object
|
|
35
37
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../lib/logging/logger.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AA2B5D
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../lib/logging/logger.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AA2B5D;;;;;;;;;;;;;;;;;;GAkBG;AACH,QAAA,MAAM,SAAS,GAAI,QAAQ,MAAM,SAEhC,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,QAAA,MAAM,SAAS,cAAgB,CAAC;AAEhC,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
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,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAGjF;;GAEG;AACH,MAAM,MAAM,yBAAyB,GAAG;IACtC,EAAE,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IACxB,IAAI,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IAC1B,GAAG,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IACzB,UAAU,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IAChC,kBAAkB,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC;IACzC,KAAK,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IAC3B,IAAI,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,CAAC;AAE1F;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,C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C,QAAQ,CAAC,mBAAmB,CAEF;IAElC,SAAgB,yBAAyB,EAAE,MAAM,EAAE,CAAS;IAC5D;;;;;;;;OAQG;IACH,SAAgB,2BAA2B,EAAE,MAAM,EAAE,CAAM;IAC3D;;;;;;;OAOG;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,OAAO,GAAG,IAAI,CAAQ;IAEtC;;;;;;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;IAkGnD;;;;;;;;;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"}
|
|
@@ -15,6 +15,8 @@ import type { HttpRequestOptions } from './polarity-request';
|
|
|
15
15
|
* @param requestOptions - request options to sanitize
|
|
16
16
|
* @param additionalPathsToSanitize - array of additional paths to sanitize in addition to the
|
|
17
17
|
* default paths.
|
|
18
|
+
* @group Requests
|
|
19
|
+
* @public
|
|
18
20
|
*/
|
|
19
21
|
export declare function sanitizeRequestOptions(requestOptions: HttpRequestOptions, additionalPathsToSanitize?: string[]): HttpRequestOptions;
|
|
20
22
|
//# sourceMappingURL=sanitize-request-options.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sanitize-request-options.d.ts","sourceRoot":"","sources":["../../../lib/requests/sanitize-request-options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAU7D
|
|
1
|
+
{"version":3,"file":"sanitize-request-options.d.ts","sourceRoot":"","sources":["../../../lib/requests/sanitize-request-options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAU7D;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,sBAAsB,CACpC,cAAc,EAAE,kBAAkB,EAClC,yBAAyB,GAAE,MAAM,EAAO,GACvC,kBAAkB,CA0BpB"}
|
|
@@ -14,6 +14,9 @@ import type { Entity, EntityType } from '@polarityio/integration-types';
|
|
|
14
14
|
* const ip = createEntity('IPv4', '8.8.8.8');
|
|
15
15
|
* const domain = createEntity('domain', 'example.com');
|
|
16
16
|
* ```
|
|
17
|
+
*
|
|
18
|
+
* @group Testing
|
|
19
|
+
* @public
|
|
17
20
|
*/
|
|
18
21
|
export declare const createEntity: (type: EntityType, value: string) => Entity;
|
|
19
22
|
//# sourceMappingURL=create-entity.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-entity.d.ts","sourceRoot":"","sources":["../../../../lib/testing/enhanced-utils/create-entity.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAwB,MAAM,+BAA+B,CAAC;AAQ9F
|
|
1
|
+
{"version":3,"file":"create-entity.d.ts","sourceRoot":"","sources":["../../../../lib/testing/enhanced-utils/create-entity.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAwB,MAAM,+BAA+B,CAAC;AAQ9F;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,YAAY,GAAI,MAAM,UAAU,EAAE,OAAO,MAAM,KAAG,MAsC9D,CAAC"}
|
|
@@ -15,6 +15,7 @@ import type { IntegrationContext } from '@polarityio/integration-types';
|
|
|
15
15
|
* // No framework — plain no-ops
|
|
16
16
|
* const ctx = createMockIntegrationContext();
|
|
17
17
|
* ```
|
|
18
|
+
* @public
|
|
18
19
|
*/
|
|
19
20
|
export type MockFnFactory = () => (...args: any[]) => any;
|
|
20
21
|
/**
|
|
@@ -27,6 +28,9 @@ export type MockFnFactory = () => (...args: any[]) => any;
|
|
|
27
28
|
* @param createMockFn - A factory that creates mock functions (e.g., `vi.fn` or `jest.fn`)
|
|
28
29
|
* @returns A fully populated `IntegrationContext` with stubbed methods
|
|
29
30
|
*
|
|
31
|
+
* @group Testing
|
|
32
|
+
* @public
|
|
33
|
+
*
|
|
30
34
|
* @example
|
|
31
35
|
* ```typescript
|
|
32
36
|
* // Vitest
|
|
@@ -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
|
|
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,kBAqCF,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.createCacheKey = createCacheKey;
|
|
7
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
8
|
+
const errors_1 = require("../errors");
|
|
9
|
+
const VALID_PREFIX = /^[a-zA-Z0-9._-]+$/;
|
|
10
|
+
const MAX_KEY_LENGTH = 250;
|
|
11
|
+
/**
|
|
12
|
+
* Creates a cache-safe key by hashing the input values with SHA-256 and
|
|
13
|
+
* prepending a descriptive prefix.
|
|
14
|
+
*
|
|
15
|
+
* Use this to derive cache keys from dynamic or sensitive data (entity values,
|
|
16
|
+
* credentials, etc.) that may contain characters outside the allowed set.
|
|
17
|
+
*
|
|
18
|
+
* @param prefix - A short descriptive label using only letters, digits, dots,
|
|
19
|
+
* underscores, and hyphens (must match `/^[a-zA-Z0-9._-]+$/`).
|
|
20
|
+
* @param value - First value to hash (required).
|
|
21
|
+
* @param values - Additional values to hash (e.g., further credentials or identifiers).
|
|
22
|
+
* @returns A key in the form `prefix_<64-char hex hash>`.
|
|
23
|
+
*
|
|
24
|
+
* @throws {@link LibraryUsageError}
|
|
25
|
+
* If `prefix` or `value` is not a string, if `prefix` is empty or contains
|
|
26
|
+
* invalid characters, if any additional value is not a string, or if the
|
|
27
|
+
* resulting key would exceed 250 characters.
|
|
28
|
+
*
|
|
29
|
+
* @group Utilities
|
|
30
|
+
* @public
|
|
31
|
+
*/
|
|
32
|
+
function createCacheKey(prefix, value, ...values) {
|
|
33
|
+
if (typeof prefix !== 'string' || !prefix || !VALID_PREFIX.test(prefix)) {
|
|
34
|
+
const received = typeof prefix !== 'string' ? `type ${typeof prefix}` : `"${prefix}"`;
|
|
35
|
+
throw new errors_1.LibraryUsageError(`Invalid cache key prefix: ${received}. ` +
|
|
36
|
+
'Prefix must be a non-empty string containing only letters, digits, dots, underscores, and hyphens ' +
|
|
37
|
+
'(must match /^[a-zA-Z0-9._-]+$/).');
|
|
38
|
+
}
|
|
39
|
+
if (typeof value !== 'string') {
|
|
40
|
+
throw new errors_1.LibraryUsageError(`Invalid cache key value: expected a string but received ${typeof value}.`);
|
|
41
|
+
}
|
|
42
|
+
for (let i = 0; i < values.length; i++) {
|
|
43
|
+
if (typeof values[i] !== 'string') {
|
|
44
|
+
throw new errors_1.LibraryUsageError(`Invalid cache key value at index ${i + 1}: expected a string but received ${typeof values[i]}.`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const hash = crypto_1.default.createHash('sha256').update(JSON.stringify([value, ...values])).digest('hex');
|
|
48
|
+
const key = `${prefix}_${hash}`;
|
|
49
|
+
if (key.length > MAX_KEY_LENGTH) {
|
|
50
|
+
throw new errors_1.LibraryUsageError(`Cache key prefix "${prefix}" is too long. ` +
|
|
51
|
+
`The generated key is ${key.length} characters but the maximum is ${MAX_KEY_LENGTH}. ` +
|
|
52
|
+
`Prefix must be at most ${MAX_KEY_LENGTH - 1 - 64} characters ` +
|
|
53
|
+
'(250 minus 1 underscore minus 64-character SHA-256 hex digest).');
|
|
54
|
+
}
|
|
55
|
+
return key;
|
|
56
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createCacheKey = void 0;
|
|
4
|
+
var create_cache_key_1 = require("./create-cache-key");
|
|
5
|
+
Object.defineProperty(exports, "createCacheKey", { enumerable: true, get: function () { return create_cache_key_1.createCacheKey; } });
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseErrorToReadableJson = void 0;
|
|
4
4
|
/**
|
|
5
|
+
* @deprecated Do not use in v2 integrations.
|
|
6
|
+
* @group Utilities
|
|
5
7
|
* @public
|
|
6
8
|
* @param error - Error instance to parse into a plain old javascript object
|
|
7
9
|
*/
|
|
@@ -36,14 +36,17 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
36
36
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.logging = exports.requests = exports.errors = void 0;
|
|
39
|
+
exports.cache = exports.logging = exports.requests = exports.errors = void 0;
|
|
40
40
|
const errors = __importStar(require("./errors"));
|
|
41
41
|
exports.errors = errors;
|
|
42
42
|
const requests = __importStar(require("./requests"));
|
|
43
43
|
exports.requests = requests;
|
|
44
44
|
const logging = __importStar(require("./logging"));
|
|
45
45
|
exports.logging = logging;
|
|
46
|
+
const cache = __importStar(require("./cache"));
|
|
47
|
+
exports.cache = cache;
|
|
46
48
|
__exportStar(require("./types"), exports);
|
|
47
49
|
__exportStar(require("./errors"), exports);
|
|
48
50
|
__exportStar(require("./requests"), exports);
|
|
49
51
|
__exportStar(require("./logging"), exports);
|
|
52
|
+
__exportStar(require("./cache"), exports);
|
|
@@ -38,6 +38,7 @@ let _logger = createDefaultLogger();
|
|
|
38
38
|
*
|
|
39
39
|
* You can now use {@link getLogger} to get the logger object anywhere within your integration codebase.
|
|
40
40
|
*
|
|
41
|
+
* @group Logging
|
|
41
42
|
* @public
|
|
42
43
|
* @param logger - the integration logger object passed into the `startup` method
|
|
43
44
|
*/
|
|
@@ -57,6 +58,7 @@ exports.setLogger = setLogger;
|
|
|
57
58
|
* logger.trace('this is a trace message');
|
|
58
59
|
* ```
|
|
59
60
|
*
|
|
61
|
+
* @group Logging
|
|
60
62
|
* @public
|
|
61
63
|
* @returns the integration's logger object
|
|
62
64
|
*/
|
|
@@ -24,6 +24,8 @@ const DEFAULT_PATHS_TO_SANITIZE = [
|
|
|
24
24
|
* @param requestOptions - request options to sanitize
|
|
25
25
|
* @param additionalPathsToSanitize - array of additional paths to sanitize in addition to the
|
|
26
26
|
* default paths.
|
|
27
|
+
* @group Requests
|
|
28
|
+
* @public
|
|
27
29
|
*/
|
|
28
30
|
function sanitizeRequestOptions(requestOptions, additionalPathsToSanitize = []) {
|
|
29
31
|
const pathsToSanitize = [
|
|
@@ -23,6 +23,9 @@ function toEntityTypeIdentifier(type) {
|
|
|
23
23
|
* const ip = createEntity('IPv4', '8.8.8.8');
|
|
24
24
|
* const domain = createEntity('domain', 'example.com');
|
|
25
25
|
* ```
|
|
26
|
+
*
|
|
27
|
+
* @group Testing
|
|
28
|
+
* @public
|
|
26
29
|
*/
|
|
27
30
|
const createEntity = (type, value) => {
|
|
28
31
|
const isDomain = /^[a-zA-Z0-9][a-zA-Z0-9-]{1,61}[a-zA-Z0-9](?:\.[a-zA-Z]{2,})+$/.test(value);
|
|
@@ -12,6 +12,9 @@ const noOp = () => () => undefined;
|
|
|
12
12
|
* @param createMockFn - A factory that creates mock functions (e.g., `vi.fn` or `jest.fn`)
|
|
13
13
|
* @returns A fully populated `IntegrationContext` with stubbed methods
|
|
14
14
|
*
|
|
15
|
+
* @group Testing
|
|
16
|
+
* @public
|
|
17
|
+
*
|
|
15
18
|
* @example
|
|
16
19
|
* ```typescript
|
|
17
20
|
* // Vitest
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.createCacheKey = createCacheKey;
|
|
7
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
8
|
+
const errors_1 = require("../errors");
|
|
9
|
+
const VALID_PREFIX = /^[a-zA-Z0-9._-]+$/;
|
|
10
|
+
const MAX_KEY_LENGTH = 250;
|
|
11
|
+
/**
|
|
12
|
+
* Creates a cache-safe key by hashing the input values with SHA-256 and
|
|
13
|
+
* prepending a descriptive prefix.
|
|
14
|
+
*
|
|
15
|
+
* Use this to derive cache keys from dynamic or sensitive data (entity values,
|
|
16
|
+
* credentials, etc.) that may contain characters outside the allowed set.
|
|
17
|
+
*
|
|
18
|
+
* @param prefix - A short descriptive label using only letters, digits, dots,
|
|
19
|
+
* underscores, and hyphens (must match `/^[a-zA-Z0-9._-]+$/`).
|
|
20
|
+
* @param value - First value to hash (required).
|
|
21
|
+
* @param values - Additional values to hash (e.g., further credentials or identifiers).
|
|
22
|
+
* @returns A key in the form `prefix_<64-char hex hash>`.
|
|
23
|
+
*
|
|
24
|
+
* @throws {@link LibraryUsageError}
|
|
25
|
+
* If `prefix` or `value` is not a string, if `prefix` is empty or contains
|
|
26
|
+
* invalid characters, if any additional value is not a string, or if the
|
|
27
|
+
* resulting key would exceed 250 characters.
|
|
28
|
+
*
|
|
29
|
+
* @group Utilities
|
|
30
|
+
* @public
|
|
31
|
+
*/
|
|
32
|
+
function createCacheKey(prefix, value, ...values) {
|
|
33
|
+
if (typeof prefix !== 'string' || !prefix || !VALID_PREFIX.test(prefix)) {
|
|
34
|
+
const received = typeof prefix !== 'string' ? `type ${typeof prefix}` : `"${prefix}"`;
|
|
35
|
+
throw new errors_1.LibraryUsageError(`Invalid cache key prefix: ${received}. ` +
|
|
36
|
+
'Prefix must be a non-empty string containing only letters, digits, dots, underscores, and hyphens ' +
|
|
37
|
+
'(must match /^[a-zA-Z0-9._-]+$/).');
|
|
38
|
+
}
|
|
39
|
+
if (typeof value !== 'string') {
|
|
40
|
+
throw new errors_1.LibraryUsageError(`Invalid cache key value: expected a string but received ${typeof value}.`);
|
|
41
|
+
}
|
|
42
|
+
for (let i = 0; i < values.length; i++) {
|
|
43
|
+
if (typeof values[i] !== 'string') {
|
|
44
|
+
throw new errors_1.LibraryUsageError(`Invalid cache key value at index ${i + 1}: expected a string but received ${typeof values[i]}.`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const hash = crypto_1.default.createHash('sha256').update(JSON.stringify([value, ...values])).digest('hex');
|
|
48
|
+
const key = `${prefix}_${hash}`;
|
|
49
|
+
if (key.length > MAX_KEY_LENGTH) {
|
|
50
|
+
throw new errors_1.LibraryUsageError(`Cache key prefix "${prefix}" is too long. ` +
|
|
51
|
+
`The generated key is ${key.length} characters but the maximum is ${MAX_KEY_LENGTH}. ` +
|
|
52
|
+
`Prefix must be at most ${MAX_KEY_LENGTH - 1 - 64} characters ` +
|
|
53
|
+
'(250 minus 1 underscore minus 64-character SHA-256 hex digest).');
|
|
54
|
+
}
|
|
55
|
+
return key;
|
|
56
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createCacheKey = void 0;
|
|
4
|
+
var create_cache_key_1 = require("./create-cache-key");
|
|
5
|
+
Object.defineProperty(exports, "createCacheKey", { enumerable: true, get: function () { return create_cache_key_1.createCacheKey; } });
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseErrorToReadableJson = void 0;
|
|
4
4
|
/**
|
|
5
|
+
* @deprecated Do not use in v2 integrations.
|
|
6
|
+
* @group Utilities
|
|
5
7
|
* @public
|
|
6
8
|
* @param error - Error instance to parse into a plain old javascript object
|
|
7
9
|
*/
|
package/dist/lib/index.docs.js
CHANGED
package/dist/lib/index.js
CHANGED
|
@@ -36,14 +36,17 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
36
36
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.logging = exports.requests = exports.errors = void 0;
|
|
39
|
+
exports.cache = exports.logging = exports.requests = exports.errors = void 0;
|
|
40
40
|
const errors = __importStar(require("./errors"));
|
|
41
41
|
exports.errors = errors;
|
|
42
42
|
const requests = __importStar(require("./requests"));
|
|
43
43
|
exports.requests = requests;
|
|
44
44
|
const logging = __importStar(require("./logging"));
|
|
45
45
|
exports.logging = logging;
|
|
46
|
+
const cache = __importStar(require("./cache"));
|
|
47
|
+
exports.cache = cache;
|
|
46
48
|
__exportStar(require("./types"), exports);
|
|
47
49
|
__exportStar(require("./errors"), exports);
|
|
48
50
|
__exportStar(require("./requests"), exports);
|
|
49
51
|
__exportStar(require("./logging"), exports);
|
|
52
|
+
__exportStar(require("./cache"), exports);
|
|
@@ -38,6 +38,7 @@ let _logger = createDefaultLogger();
|
|
|
38
38
|
*
|
|
39
39
|
* You can now use {@link getLogger} to get the logger object anywhere within your integration codebase.
|
|
40
40
|
*
|
|
41
|
+
* @group Logging
|
|
41
42
|
* @public
|
|
42
43
|
* @param logger - the integration logger object passed into the `startup` method
|
|
43
44
|
*/
|
|
@@ -57,6 +58,7 @@ exports.setLogger = setLogger;
|
|
|
57
58
|
* logger.trace('this is a trace message');
|
|
58
59
|
* ```
|
|
59
60
|
*
|
|
61
|
+
* @group Logging
|
|
60
62
|
* @public
|
|
61
63
|
* @returns the integration's logger object
|
|
62
64
|
*/
|
|
@@ -24,6 +24,8 @@ const DEFAULT_PATHS_TO_SANITIZE = [
|
|
|
24
24
|
* @param requestOptions - request options to sanitize
|
|
25
25
|
* @param additionalPathsToSanitize - array of additional paths to sanitize in addition to the
|
|
26
26
|
* default paths.
|
|
27
|
+
* @group Requests
|
|
28
|
+
* @public
|
|
27
29
|
*/
|
|
28
30
|
function sanitizeRequestOptions(requestOptions, additionalPathsToSanitize = []) {
|
|
29
31
|
const pathsToSanitize = [
|
|
@@ -23,6 +23,9 @@ function toEntityTypeIdentifier(type) {
|
|
|
23
23
|
* const ip = createEntity('IPv4', '8.8.8.8');
|
|
24
24
|
* const domain = createEntity('domain', 'example.com');
|
|
25
25
|
* ```
|
|
26
|
+
*
|
|
27
|
+
* @group Testing
|
|
28
|
+
* @public
|
|
26
29
|
*/
|
|
27
30
|
const createEntity = (type, value) => {
|
|
28
31
|
const isDomain = /^[a-zA-Z0-9][a-zA-Z0-9-]{1,61}[a-zA-Z0-9](?:\.[a-zA-Z]{2,})+$/.test(value);
|
|
@@ -12,6 +12,9 @@ const noOp = () => () => undefined;
|
|
|
12
12
|
* @param createMockFn - A factory that creates mock functions (e.g., `vi.fn` or `jest.fn`)
|
|
13
13
|
* @returns A fully populated `IntegrationContext` with stubbed methods
|
|
14
14
|
*
|
|
15
|
+
* @group Testing
|
|
16
|
+
* @public
|
|
17
|
+
*
|
|
15
18
|
* @example
|
|
16
19
|
* ```typescript
|
|
17
20
|
* // Vitest
|