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.
Files changed (113) hide show
  1. package/dist/dts/errors/integration-error.d.ts +11 -11
  2. package/dist/dts/errors/integration-error.d.ts.map +1 -1
  3. package/dist/dts/errors/parse-error-to-readable-json.d.ts +2 -2
  4. package/dist/dts/errors/parse-error-to-readable-json.d.ts.map +1 -1
  5. package/dist/dts/index.d.ts +1 -3
  6. package/dist/dts/index.d.ts.map +1 -1
  7. package/dist/dts/index.docs.d.ts +1 -1
  8. package/dist/dts/lib/errors/integration-error.d.ts +11 -11
  9. package/dist/dts/lib/errors/integration-error.d.ts.map +1 -1
  10. package/dist/dts/lib/errors/parse-error-to-readable-json.d.ts +2 -2
  11. package/dist/dts/lib/errors/parse-error-to-readable-json.d.ts.map +1 -1
  12. package/dist/dts/lib/index.d.ts +1 -3
  13. package/dist/dts/lib/index.d.ts.map +1 -1
  14. package/dist/dts/lib/index.docs.d.ts +1 -1
  15. package/dist/dts/lib/logging/logger.d.ts +1 -12
  16. package/dist/dts/lib/logging/logger.d.ts.map +1 -1
  17. package/dist/dts/lib/requests/polarity-request.d.ts +93 -68
  18. package/dist/dts/lib/requests/polarity-request.d.ts.map +1 -1
  19. package/dist/dts/lib/testing/enhanced-utils/create-entity.d.ts +17 -1
  20. package/dist/dts/lib/testing/enhanced-utils/create-entity.d.ts.map +1 -1
  21. package/dist/dts/lib/testing/enhanced-utils/create-mock-integration-context.d.ts +42 -2
  22. package/dist/dts/lib/testing/enhanced-utils/create-mock-integration-context.d.ts.map +1 -1
  23. package/dist/dts/lib/testing/index.d.ts +0 -3
  24. package/dist/dts/lib/testing/index.d.ts.map +1 -1
  25. package/dist/dts/lib/types.d.ts +89 -84
  26. package/dist/dts/lib/types.d.ts.map +1 -1
  27. package/dist/dts/logging/logger.d.ts +1 -12
  28. package/dist/dts/logging/logger.d.ts.map +1 -1
  29. package/dist/dts/requests/polarity-request.d.ts +93 -68
  30. package/dist/dts/requests/polarity-request.d.ts.map +1 -1
  31. package/dist/dts/testing/enhanced-utils/create-entity.d.ts +17 -1
  32. package/dist/dts/testing/enhanced-utils/create-entity.d.ts.map +1 -1
  33. package/dist/dts/testing/enhanced-utils/create-mock-integration-context.d.ts +42 -2
  34. package/dist/dts/testing/enhanced-utils/create-mock-integration-context.d.ts.map +1 -1
  35. package/dist/dts/testing/index.d.ts +0 -3
  36. package/dist/dts/testing/index.d.ts.map +1 -1
  37. package/dist/dts/tsdoc-metadata.json +1 -1
  38. package/dist/dts/types.d.ts +89 -84
  39. package/dist/dts/types.d.ts.map +1 -1
  40. package/dist/es/lib/errors/integration-error.js +7 -4
  41. package/dist/es/lib/index.docs.js +1 -1
  42. package/dist/es/lib/index.js +1 -5
  43. package/dist/es/lib/logging/logger.js +18 -7
  44. package/dist/es/lib/requests/polarity-request.js +103 -126
  45. package/dist/es/lib/testing/enhanced-utils/create-entity.js +31 -5
  46. package/dist/es/lib/testing/enhanced-utils/create-mock-integration-context.js +54 -27
  47. package/dist/es/lib/testing/index.js +0 -3
  48. package/dist/es/lib/types.js +2 -1
  49. package/dist/lib/errors/integration-error.js +7 -4
  50. package/dist/lib/index.docs.js +1 -1
  51. package/dist/lib/index.js +1 -5
  52. package/dist/lib/logging/logger.js +18 -7
  53. package/dist/lib/requests/polarity-request.js +103 -126
  54. package/dist/lib/testing/enhanced-utils/create-entity.js +31 -5
  55. package/dist/lib/testing/enhanced-utils/create-mock-integration-context.js +54 -27
  56. package/dist/lib/testing/index.js +0 -3
  57. package/dist/lib/types.js +2 -1
  58. package/dist/polarity-integration-utils.d.ts +264 -594
  59. package/package.json +8 -11
  60. package/dist/dts/context/cache.d.ts +0 -149
  61. package/dist/dts/context/cache.d.ts.map +0 -1
  62. package/dist/dts/context/index.d.ts +0 -3
  63. package/dist/dts/context/index.d.ts.map +0 -1
  64. package/dist/dts/context/integration-context.d.ts +0 -16
  65. package/dist/dts/context/integration-context.d.ts.map +0 -1
  66. package/dist/dts/lib/context/cache.d.ts +0 -149
  67. package/dist/dts/lib/context/cache.d.ts.map +0 -1
  68. package/dist/dts/lib/context/index.d.ts +0 -3
  69. package/dist/dts/lib/context/index.d.ts.map +0 -1
  70. package/dist/dts/lib/context/integration-context.d.ts +0 -16
  71. package/dist/dts/lib/context/integration-context.d.ts.map +0 -1
  72. package/dist/dts/lib/testing/enhanced-utils/mock-request.d.ts +0 -14
  73. package/dist/dts/lib/testing/enhanced-utils/mock-request.d.ts.map +0 -1
  74. package/dist/dts/lib/testing/enhanced-utils/validate-integration.d.ts +0 -8
  75. package/dist/dts/lib/testing/enhanced-utils/validate-integration.d.ts.map +0 -1
  76. package/dist/dts/lib/testing/test-factory/create-integration-tests.d.ts +0 -6
  77. package/dist/dts/lib/testing/test-factory/create-integration-tests.d.ts.map +0 -1
  78. package/dist/dts/lib/testing/test-factory/test-do-lookup.d.ts +0 -7
  79. package/dist/dts/lib/testing/test-factory/test-do-lookup.d.ts.map +0 -1
  80. package/dist/dts/lib/testing/test-factory/test-on-message.d.ts +0 -8
  81. package/dist/dts/lib/testing/test-factory/test-on-message.d.ts.map +0 -1
  82. package/dist/dts/lib/zod-types.d.ts +0 -278
  83. package/dist/dts/lib/zod-types.d.ts.map +0 -1
  84. package/dist/dts/testing/enhanced-utils/mock-request.d.ts +0 -14
  85. package/dist/dts/testing/enhanced-utils/mock-request.d.ts.map +0 -1
  86. package/dist/dts/testing/enhanced-utils/validate-integration.d.ts +0 -8
  87. package/dist/dts/testing/enhanced-utils/validate-integration.d.ts.map +0 -1
  88. package/dist/dts/testing/test-factory/create-integration-tests.d.ts +0 -6
  89. package/dist/dts/testing/test-factory/create-integration-tests.d.ts.map +0 -1
  90. package/dist/dts/testing/test-factory/test-do-lookup.d.ts +0 -7
  91. package/dist/dts/testing/test-factory/test-do-lookup.d.ts.map +0 -1
  92. package/dist/dts/testing/test-factory/test-on-message.d.ts +0 -8
  93. package/dist/dts/testing/test-factory/test-on-message.d.ts.map +0 -1
  94. package/dist/dts/zod-types.d.ts +0 -278
  95. package/dist/dts/zod-types.d.ts.map +0 -1
  96. package/dist/es/lib/context/cache.js +0 -2
  97. package/dist/es/lib/context/index.js +0 -18
  98. package/dist/es/lib/context/integration-context.js +0 -2
  99. package/dist/es/lib/testing/enhanced-utils/mock-request.js +0 -22
  100. package/dist/es/lib/testing/enhanced-utils/validate-integration.js +0 -159
  101. package/dist/es/lib/testing/test-factory/create-integration-tests.js +0 -53
  102. package/dist/es/lib/testing/test-factory/test-do-lookup.js +0 -24
  103. package/dist/es/lib/testing/test-factory/test-on-message.js +0 -24
  104. package/dist/es/lib/zod-types.js +0 -206
  105. package/dist/lib/context/cache.js +0 -2
  106. package/dist/lib/context/index.js +0 -18
  107. package/dist/lib/context/integration-context.js +0 -2
  108. package/dist/lib/testing/enhanced-utils/mock-request.js +0 -22
  109. package/dist/lib/testing/enhanced-utils/validate-integration.js +0 -159
  110. package/dist/lib/testing/test-factory/create-integration-tests.js +0 -53
  111. package/dist/lib/testing/test-factory/test-do-lookup.js +0 -24
  112. package/dist/lib/testing/test-factory/test-on-message.js +0 -24
  113. 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.1.7",
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
- "bottleneck": "^2.19.5",
107
- "lodash": "^4.17.23",
108
- "postman-request": "^2.88.1-postman.48",
109
- "zod": "^4.3.6"
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,3 +0,0 @@
1
- export * from './cache';
2
- export * from './integration-context';
3
- //# sourceMappingURL=index.d.ts.map
@@ -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,3 +0,0 @@
1
- export * from './cache';
2
- export * from './integration-context';
3
- //# sourceMappingURL=index.d.ts.map
@@ -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,6 +0,0 @@
1
- import { Integration } from '../../types';
2
- export declare const createIntegrationTests: (integration: Integration) => {
3
- testDoLookup: any;
4
- testOnMessage: any;
5
- };
6
- //# sourceMappingURL=create-integration-tests.d.ts.map
@@ -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"}