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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "polarity-integration-utils",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "A utility library for building Polarity Integrations",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -39,11 +39,6 @@
|
|
|
39
39
|
"require": "./dist/lib/helpers/index.js",
|
|
40
40
|
"types": "./dist/dts/helpers/index.d.ts"
|
|
41
41
|
},
|
|
42
|
-
"./context": {
|
|
43
|
-
"import": "./dist/es/context/index.js",
|
|
44
|
-
"require": "./dist/lib/context/index.js",
|
|
45
|
-
"types": "./dist/dts/context/index.d.ts"
|
|
46
|
-
},
|
|
47
42
|
"./testing": {
|
|
48
43
|
"import": "./dist/es/testing/index.js",
|
|
49
44
|
"require": "./dist/lib/testing/index.js",
|
|
@@ -86,6 +81,7 @@
|
|
|
86
81
|
"devDependencies": {
|
|
87
82
|
"@eslint/js": "^9.39.4",
|
|
88
83
|
"@microsoft/api-extractor": "^7.57.7",
|
|
84
|
+
"@polarityio/integration-types": "^1.1.0",
|
|
89
85
|
"@types/jest": "^30.0.0",
|
|
90
86
|
"@types/lodash": "^4.17.24",
|
|
91
87
|
"@types/node": "^20.14.8",
|
|
@@ -103,10 +99,11 @@
|
|
|
103
99
|
"typescript-eslint": "^8.56.1"
|
|
104
100
|
},
|
|
105
101
|
"dependencies": {
|
|
106
|
-
"
|
|
107
|
-
"
|
|
108
|
-
|
|
109
|
-
|
|
102
|
+
"lodash": "^4.18.1",
|
|
103
|
+
"postman-request": "^2.88.1-postman.48"
|
|
104
|
+
},
|
|
105
|
+
"peerDependencies": {
|
|
106
|
+
"@polarityio/integration-types": ">=1.1.0"
|
|
110
107
|
},
|
|
111
108
|
"sideEffects": false
|
|
112
|
-
}
|
|
109
|
+
}
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Cache operation options
|
|
3
|
-
*/
|
|
4
|
-
export interface CacheOptions {
|
|
5
|
-
/** Time-to-live in seconds. If not specified, uses default TTL */
|
|
6
|
-
ttl?: number;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Global cache operations - shared across all integrations and users
|
|
10
|
-
* Use for system-wide statistics, feature flags, or shared configuration
|
|
11
|
-
*/
|
|
12
|
-
export interface GlobalCache {
|
|
13
|
-
/**
|
|
14
|
-
* Get a value from global cache
|
|
15
|
-
* @param key - The cache key
|
|
16
|
-
* @returns Promise that resolves to the cached value or null if not found
|
|
17
|
-
* @example
|
|
18
|
-
* const totalLookups = await cache.global.get('total_lookups') || 0;
|
|
19
|
-
*/
|
|
20
|
-
get(key: string): Promise<unknown>;
|
|
21
|
-
/**
|
|
22
|
-
* Set a value in global cache
|
|
23
|
-
* @param key - The cache key
|
|
24
|
-
* @param value - The value to cache (must be JSON serializable)
|
|
25
|
-
* @param options - Cache options including TTL
|
|
26
|
-
* @returns Promise that resolves when the operation completes
|
|
27
|
-
* @example
|
|
28
|
-
* await cache.global.set('total_lookups', count + 1, \{ ttl: 86400 \});
|
|
29
|
-
*/
|
|
30
|
-
set(key: string, value: unknown, options?: CacheOptions): Promise<void>;
|
|
31
|
-
/**
|
|
32
|
-
* Delete a value from global cache
|
|
33
|
-
* @param key - The cache key to delete
|
|
34
|
-
* @returns Promise that resolves when the operation completes
|
|
35
|
-
* @example
|
|
36
|
-
* await cache.global.delete('feature_flags');
|
|
37
|
-
*/
|
|
38
|
-
delete(key: string): Promise<void>;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Integration-scoped cache operations - shared across all users of a specific integration
|
|
42
|
-
* Use for API responses, configuration, or data that's the same for all users
|
|
43
|
-
*/
|
|
44
|
-
export interface IntegrationCache {
|
|
45
|
-
/**
|
|
46
|
-
* Get a value from integration cache
|
|
47
|
-
* @param key - The cache key
|
|
48
|
-
* @returns Promise that resolves to the cached value or null if not found
|
|
49
|
-
* @example
|
|
50
|
-
* const config = await cache.integration.get('api_config');
|
|
51
|
-
*/
|
|
52
|
-
get(key: string): Promise<unknown>;
|
|
53
|
-
/**
|
|
54
|
-
* Set a value in integration cache
|
|
55
|
-
* @param key - The cache key
|
|
56
|
-
* @param value - The value to cache (must be JSON serializable)
|
|
57
|
-
* @param options - Cache options including TTL
|
|
58
|
-
* @returns Promise that resolves when the operation completes
|
|
59
|
-
* @example
|
|
60
|
-
* await cache.integration.set('lookup_ip_1.1.1.1', result, \{ ttl: 300 \});
|
|
61
|
-
*/
|
|
62
|
-
set(key: string, value: unknown, options?: CacheOptions): Promise<void>;
|
|
63
|
-
/**
|
|
64
|
-
* Delete a value from integration cache
|
|
65
|
-
* @param key - The cache key to delete
|
|
66
|
-
* @returns Promise that resolves when the operation completes
|
|
67
|
-
* @example
|
|
68
|
-
* await cache.integration.delete('expired_config');
|
|
69
|
-
*/
|
|
70
|
-
delete(key: string): Promise<void>;
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* User-scoped cache operations - specific to individual users
|
|
74
|
-
* Use for user preferences, recent activity, or personalized data
|
|
75
|
-
*/
|
|
76
|
-
export interface UserCache {
|
|
77
|
-
/**
|
|
78
|
-
* Get a value from user cache
|
|
79
|
-
* @param key - The cache key
|
|
80
|
-
* @returns Promise that resolves to the cached value or null if not found
|
|
81
|
-
* @example
|
|
82
|
-
* const preferences = await cache.user.get('preferences');
|
|
83
|
-
*/
|
|
84
|
-
get(key: string): Promise<unknown>;
|
|
85
|
-
/**
|
|
86
|
-
* Set a value in user cache
|
|
87
|
-
* @param key - The cache key
|
|
88
|
-
* @param value - The value to cache (must be JSON serializable)
|
|
89
|
-
* @param options - Cache options including TTL
|
|
90
|
-
* @returns Promise that resolves when the operation completes
|
|
91
|
-
* @example
|
|
92
|
-
* await cache.user.set('recent_lookups', lookups, \{ ttl: 3600 \});
|
|
93
|
-
*/
|
|
94
|
-
set(key: string, value: unknown, options?: CacheOptions): Promise<void>;
|
|
95
|
-
/**
|
|
96
|
-
* Delete a value from user cache
|
|
97
|
-
* @param key - The cache key to delete
|
|
98
|
-
* @returns Promise that resolves when the operation completes
|
|
99
|
-
* @example
|
|
100
|
-
* await cache.user.delete('preferences');
|
|
101
|
-
*/
|
|
102
|
-
delete(key: string): Promise<void>;
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Main cache interface providing hierarchical caching with three scopes
|
|
106
|
-
*
|
|
107
|
-
* Cache Hierarchy:
|
|
108
|
-
* - Global: System-wide data shared across all integrations
|
|
109
|
-
* - Integration: Data shared among all users of a specific integration
|
|
110
|
-
* - User: User-specific data within an integration context
|
|
111
|
-
*
|
|
112
|
-
* Best Practices:
|
|
113
|
-
* - Use appropriate TTL values to prevent stale data
|
|
114
|
-
* - Handle cache misses gracefully (operations may return null)
|
|
115
|
-
* - Wrap cache operations in try/catch blocks
|
|
116
|
-
* - Use descriptive keys that won't conflict with other data
|
|
117
|
-
*
|
|
118
|
-
* @example
|
|
119
|
-
* ```javascript
|
|
120
|
-
* // In your integration functions:
|
|
121
|
-
* async function doLookup(entities, options, context) {
|
|
122
|
-
* const cache = context?.cache;
|
|
123
|
-
* if (!cache) return generateFreshData();
|
|
124
|
-
*
|
|
125
|
-
* try {
|
|
126
|
-
* // Check integration cache first
|
|
127
|
-
* const cached = await cache.integration.get(`lookup_${entity.value}`);
|
|
128
|
-
* if (cached) return cached;
|
|
129
|
-
*
|
|
130
|
-
* // Generate and cache new data
|
|
131
|
-
* const result = await apiCall(entity);
|
|
132
|
-
* await cache.integration.set(`lookup_${entity.value}`, result, { ttl: 300 });
|
|
133
|
-
* return result;
|
|
134
|
-
* } catch (error) {
|
|
135
|
-
* console.error('Cache error:', error);
|
|
136
|
-
* return generateFreshData(); // Fallback
|
|
137
|
-
* }
|
|
138
|
-
* }
|
|
139
|
-
* ```
|
|
140
|
-
*/
|
|
141
|
-
export interface PolarityCache {
|
|
142
|
-
/** Global cache operations - shared across all integrations and users */
|
|
143
|
-
global: GlobalCache;
|
|
144
|
-
/** Integration-scoped cache operations - shared across all users of a specific integration */
|
|
145
|
-
integration: IntegrationCache;
|
|
146
|
-
/** User-scoped cache operations - specific to individual users */
|
|
147
|
-
user: UserCache;
|
|
148
|
-
}
|
|
149
|
-
//# sourceMappingURL=cache.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../../lib/context/cache.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,kEAAkE;IAClE,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B;;;;;;OAMG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAEnC;;;;;;;;OAQG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAExE;;;;;;OAMG;IACH,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACpC;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;;;;OAMG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAEnC;;;;;;;;OAQG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAExE;;;;;;OAMG;IACH,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACpC;AAED;;;GAGG;AACH,MAAM,WAAW,SAAS;IACxB;;;;;;OAMG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAEnC;;;;;;;;OAQG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAExE;;;;;;OAMG;IACH,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACpC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,MAAM,WAAW,aAAa;IAC5B,yEAAyE;IACzE,MAAM,EAAE,WAAW,CAAC;IAEpB,8FAA8F;IAC9F,WAAW,EAAE,gBAAgB,CAAC;IAE9B,kEAAkE;IAClE,IAAI,EAAE,SAAS,CAAC;CACjB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/context/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,uBAAuB,CAAC"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Logger } from '../logging';
|
|
2
|
-
import { PolarityCache } from './cache';
|
|
3
|
-
/**
|
|
4
|
-
* Integration context provided to integration functions
|
|
5
|
-
*/
|
|
6
|
-
export interface IntegrationContext {
|
|
7
|
-
/** Cache client for hierarchical caching operations */
|
|
8
|
-
cache: PolarityCache;
|
|
9
|
-
/** Integration identifier */
|
|
10
|
-
integrationId: string;
|
|
11
|
-
/** User identifier */
|
|
12
|
-
userId?: string;
|
|
13
|
-
/** Logger instance */
|
|
14
|
-
logger: Logger;
|
|
15
|
-
}
|
|
16
|
-
//# sourceMappingURL=integration-context.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"integration-context.d.ts","sourceRoot":"","sources":["../../../lib/context/integration-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExC;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,uDAAuD;IACvD,KAAK,EAAE,aAAa,CAAC;IAErB,6BAA6B;IAC7B,aAAa,EAAE,MAAM,CAAC;IAEtB,sBAAsB;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,sBAAsB;IACtB,MAAM,EAAE,MAAM,CAAC;CAChB"}
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Cache operation options
|
|
3
|
-
*/
|
|
4
|
-
export interface CacheOptions {
|
|
5
|
-
/** Time-to-live in seconds. If not specified, uses default TTL */
|
|
6
|
-
ttl?: number;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Global cache operations - shared across all integrations and users
|
|
10
|
-
* Use for system-wide statistics, feature flags, or shared configuration
|
|
11
|
-
*/
|
|
12
|
-
export interface GlobalCache {
|
|
13
|
-
/**
|
|
14
|
-
* Get a value from global cache
|
|
15
|
-
* @param key - The cache key
|
|
16
|
-
* @returns Promise that resolves to the cached value or null if not found
|
|
17
|
-
* @example
|
|
18
|
-
* const totalLookups = await cache.global.get('total_lookups') || 0;
|
|
19
|
-
*/
|
|
20
|
-
get(key: string): Promise<unknown>;
|
|
21
|
-
/**
|
|
22
|
-
* Set a value in global cache
|
|
23
|
-
* @param key - The cache key
|
|
24
|
-
* @param value - The value to cache (must be JSON serializable)
|
|
25
|
-
* @param options - Cache options including TTL
|
|
26
|
-
* @returns Promise that resolves when the operation completes
|
|
27
|
-
* @example
|
|
28
|
-
* await cache.global.set('total_lookups', count + 1, \{ ttl: 86400 \});
|
|
29
|
-
*/
|
|
30
|
-
set(key: string, value: unknown, options?: CacheOptions): Promise<void>;
|
|
31
|
-
/**
|
|
32
|
-
* Delete a value from global cache
|
|
33
|
-
* @param key - The cache key to delete
|
|
34
|
-
* @returns Promise that resolves when the operation completes
|
|
35
|
-
* @example
|
|
36
|
-
* await cache.global.delete('feature_flags');
|
|
37
|
-
*/
|
|
38
|
-
delete(key: string): Promise<void>;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Integration-scoped cache operations - shared across all users of a specific integration
|
|
42
|
-
* Use for API responses, configuration, or data that's the same for all users
|
|
43
|
-
*/
|
|
44
|
-
export interface IntegrationCache {
|
|
45
|
-
/**
|
|
46
|
-
* Get a value from integration cache
|
|
47
|
-
* @param key - The cache key
|
|
48
|
-
* @returns Promise that resolves to the cached value or null if not found
|
|
49
|
-
* @example
|
|
50
|
-
* const config = await cache.integration.get('api_config');
|
|
51
|
-
*/
|
|
52
|
-
get(key: string): Promise<unknown>;
|
|
53
|
-
/**
|
|
54
|
-
* Set a value in integration cache
|
|
55
|
-
* @param key - The cache key
|
|
56
|
-
* @param value - The value to cache (must be JSON serializable)
|
|
57
|
-
* @param options - Cache options including TTL
|
|
58
|
-
* @returns Promise that resolves when the operation completes
|
|
59
|
-
* @example
|
|
60
|
-
* await cache.integration.set('lookup_ip_1.1.1.1', result, \{ ttl: 300 \});
|
|
61
|
-
*/
|
|
62
|
-
set(key: string, value: unknown, options?: CacheOptions): Promise<void>;
|
|
63
|
-
/**
|
|
64
|
-
* Delete a value from integration cache
|
|
65
|
-
* @param key - The cache key to delete
|
|
66
|
-
* @returns Promise that resolves when the operation completes
|
|
67
|
-
* @example
|
|
68
|
-
* await cache.integration.delete('expired_config');
|
|
69
|
-
*/
|
|
70
|
-
delete(key: string): Promise<void>;
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* User-scoped cache operations - specific to individual users
|
|
74
|
-
* Use for user preferences, recent activity, or personalized data
|
|
75
|
-
*/
|
|
76
|
-
export interface UserCache {
|
|
77
|
-
/**
|
|
78
|
-
* Get a value from user cache
|
|
79
|
-
* @param key - The cache key
|
|
80
|
-
* @returns Promise that resolves to the cached value or null if not found
|
|
81
|
-
* @example
|
|
82
|
-
* const preferences = await cache.user.get('preferences');
|
|
83
|
-
*/
|
|
84
|
-
get(key: string): Promise<unknown>;
|
|
85
|
-
/**
|
|
86
|
-
* Set a value in user cache
|
|
87
|
-
* @param key - The cache key
|
|
88
|
-
* @param value - The value to cache (must be JSON serializable)
|
|
89
|
-
* @param options - Cache options including TTL
|
|
90
|
-
* @returns Promise that resolves when the operation completes
|
|
91
|
-
* @example
|
|
92
|
-
* await cache.user.set('recent_lookups', lookups, \{ ttl: 3600 \});
|
|
93
|
-
*/
|
|
94
|
-
set(key: string, value: unknown, options?: CacheOptions): Promise<void>;
|
|
95
|
-
/**
|
|
96
|
-
* Delete a value from user cache
|
|
97
|
-
* @param key - The cache key to delete
|
|
98
|
-
* @returns Promise that resolves when the operation completes
|
|
99
|
-
* @example
|
|
100
|
-
* await cache.user.delete('preferences');
|
|
101
|
-
*/
|
|
102
|
-
delete(key: string): Promise<void>;
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Main cache interface providing hierarchical caching with three scopes
|
|
106
|
-
*
|
|
107
|
-
* Cache Hierarchy:
|
|
108
|
-
* - Global: System-wide data shared across all integrations
|
|
109
|
-
* - Integration: Data shared among all users of a specific integration
|
|
110
|
-
* - User: User-specific data within an integration context
|
|
111
|
-
*
|
|
112
|
-
* Best Practices:
|
|
113
|
-
* - Use appropriate TTL values to prevent stale data
|
|
114
|
-
* - Handle cache misses gracefully (operations may return null)
|
|
115
|
-
* - Wrap cache operations in try/catch blocks
|
|
116
|
-
* - Use descriptive keys that won't conflict with other data
|
|
117
|
-
*
|
|
118
|
-
* @example
|
|
119
|
-
* ```javascript
|
|
120
|
-
* // In your integration functions:
|
|
121
|
-
* async function doLookup(entities, options, context) {
|
|
122
|
-
* const cache = context?.cache;
|
|
123
|
-
* if (!cache) return generateFreshData();
|
|
124
|
-
*
|
|
125
|
-
* try {
|
|
126
|
-
* // Check integration cache first
|
|
127
|
-
* const cached = await cache.integration.get(`lookup_${entity.value}`);
|
|
128
|
-
* if (cached) return cached;
|
|
129
|
-
*
|
|
130
|
-
* // Generate and cache new data
|
|
131
|
-
* const result = await apiCall(entity);
|
|
132
|
-
* await cache.integration.set(`lookup_${entity.value}`, result, { ttl: 300 });
|
|
133
|
-
* return result;
|
|
134
|
-
* } catch (error) {
|
|
135
|
-
* console.error('Cache error:', error);
|
|
136
|
-
* return generateFreshData(); // Fallback
|
|
137
|
-
* }
|
|
138
|
-
* }
|
|
139
|
-
* ```
|
|
140
|
-
*/
|
|
141
|
-
export interface PolarityCache {
|
|
142
|
-
/** Global cache operations - shared across all integrations and users */
|
|
143
|
-
global: GlobalCache;
|
|
144
|
-
/** Integration-scoped cache operations - shared across all users of a specific integration */
|
|
145
|
-
integration: IntegrationCache;
|
|
146
|
-
/** User-scoped cache operations - specific to individual users */
|
|
147
|
-
user: UserCache;
|
|
148
|
-
}
|
|
149
|
-
//# sourceMappingURL=cache.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../../../lib/context/cache.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,kEAAkE;IAClE,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B;;;;;;OAMG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAEnC;;;;;;;;OAQG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAExE;;;;;;OAMG;IACH,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACpC;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;;;;OAMG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAEnC;;;;;;;;OAQG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAExE;;;;;;OAMG;IACH,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACpC;AAED;;;GAGG;AACH,MAAM,WAAW,SAAS;IACxB;;;;;;OAMG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAEnC;;;;;;;;OAQG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAExE;;;;;;OAMG;IACH,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACpC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,MAAM,WAAW,aAAa;IAC5B,yEAAyE;IACzE,MAAM,EAAE,WAAW,CAAC;IAEpB,8FAA8F;IAC9F,WAAW,EAAE,gBAAgB,CAAC;IAE9B,kEAAkE;IAClE,IAAI,EAAE,SAAS,CAAC;CACjB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../lib/context/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,uBAAuB,CAAC"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Logger } from '../logging';
|
|
2
|
-
import { PolarityCache } from './cache';
|
|
3
|
-
/**
|
|
4
|
-
* Integration context provided to integration functions
|
|
5
|
-
*/
|
|
6
|
-
export interface IntegrationContext {
|
|
7
|
-
/** Cache client for hierarchical caching operations */
|
|
8
|
-
cache: PolarityCache;
|
|
9
|
-
/** Integration identifier */
|
|
10
|
-
integrationId: string;
|
|
11
|
-
/** User identifier */
|
|
12
|
-
userId?: string;
|
|
13
|
-
/** Logger instance */
|
|
14
|
-
logger: Logger;
|
|
15
|
-
}
|
|
16
|
-
//# sourceMappingURL=integration-context.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"integration-context.d.ts","sourceRoot":"","sources":["../../../../lib/context/integration-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExC;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,uDAAuD;IACvD,KAAK,EAAE,aAAa,CAAC;IAErB,6BAA6B;IAC7B,aAAa,EAAE,MAAM,CAAC;IAEtB,sBAAsB;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,sBAAsB;IACtB,MAAM,EAAE,MAAM,CAAC;CAChB"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { PolarityRequest } from '../../requests/polarity-request';
|
|
2
|
-
export declare const mockRequest: () => {
|
|
3
|
-
PolarityRequestMock: jest.MockedClass<typeof PolarityRequest>;
|
|
4
|
-
mockRequest: {
|
|
5
|
-
get: jest.Mock<any, any, any>;
|
|
6
|
-
post: jest.Mock<any, any, any>;
|
|
7
|
-
put: jest.Mock<any, any, any>;
|
|
8
|
-
delete: jest.Mock<any, any, any>;
|
|
9
|
-
patch: jest.Mock<any, any, any>;
|
|
10
|
-
head: jest.Mock<any, any, any>;
|
|
11
|
-
options: jest.Mock<any, any, any>;
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
//# sourceMappingURL=mock-request.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mock-request.d.ts","sourceRoot":"","sources":["../../../../../lib/testing/enhanced-utils/mock-request.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAIlE,eAAO,MAAM,WAAW;yBAcoB,IAAI,CAAC,WAAW,CAAC,OAAO,eAAe,CAAC;;;;;;;;;;CAGnF,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { Integration, IntegrationConfig } from '../../types';
|
|
2
|
-
export interface ValidationResult {
|
|
3
|
-
isValid: boolean;
|
|
4
|
-
errors: string[];
|
|
5
|
-
warnings: string[];
|
|
6
|
-
}
|
|
7
|
-
export declare const validateIntegration: (integration: Integration, config?: IntegrationConfig) => ValidationResult;
|
|
8
|
-
//# sourceMappingURL=validate-integration.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validate-integration.d.ts","sourceRoot":"","sources":["../../../../../lib/testing/enhanced-utils/validate-integration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAsB,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAKjF,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,eAAO,MAAM,mBAAmB,GAC9B,aAAa,WAAW,EACxB,SAAS,iBAAiB,KACzB,gBAoCF,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-integration-tests.d.ts","sourceRoot":"","sources":["../../../../../lib/testing/test-factory/create-integration-tests.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAO1C,eAAO,MAAM,sBAAsB,GAAI,aAAa,WAAW;;;CAY9D,CAAC"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { DoLookupResult, DoLookupUserOptions, Entity, Integration } from '../../types';
|
|
2
|
-
export declare const testDoLookup: (integration: Integration, description: string, { entities, options, expected }: {
|
|
3
|
-
entities: Entity[];
|
|
4
|
-
options: DoLookupUserOptions;
|
|
5
|
-
expected: DoLookupResult;
|
|
6
|
-
}) => void;
|
|
7
|
-
//# sourceMappingURL=test-do-lookup.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"test-do-lookup.d.ts","sourceRoot":"","sources":["../../../../../lib/testing/test-factory/test-do-lookup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAIvF,eAAO,MAAM,YAAY,GACvB,aAAa,WAAW,EACxB,aAAa,MAAM,EACnB,iCAIG;IACD,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,OAAO,EAAE,mBAAmB,CAAC;IAC7B,QAAQ,EAAE,cAAc,CAAC;CAC1B,SAkBF,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { DoLookupUserOptions, Integration } from '../../types';
|
|
2
|
-
export declare const testOnMessage: (integration: Integration, description: string, { command, args, expected, options }: {
|
|
3
|
-
command: string;
|
|
4
|
-
args: Record<string, unknown>;
|
|
5
|
-
expected: unknown;
|
|
6
|
-
options?: DoLookupUserOptions;
|
|
7
|
-
}) => void;
|
|
8
|
-
//# sourceMappingURL=test-on-message.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"test-on-message.d.ts","sourceRoot":"","sources":["../../../../../lib/testing/test-factory/test-on-message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/D,eAAO,MAAM,aAAa,GACxB,aAAa,WAAW,EACxB,aAAa,MAAM,EACnB,sCAKG;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,mBAAmB,CAAC;CAC/B,SAmBF,CAAC"}
|