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
|
@@ -1,36 +1,63 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createMockIntegrationContext = void 0;
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
4
|
+
const noOp = () => () => undefined;
|
|
5
|
+
/**
|
|
6
|
+
* Creates a mock `IntegrationContext`
|
|
7
|
+
* with stubbed logger, cache, and polling methods.
|
|
8
|
+
*
|
|
9
|
+
* Pass your testing framework's mock function factory to enable spy capabilities
|
|
10
|
+
* (e.g., `toHaveBeenCalledWith()`). When omitted, plain no-op stubs are used.
|
|
11
|
+
*
|
|
12
|
+
* @param createMockFn - A factory that creates mock functions (e.g., `vi.fn` or `jest.fn`)
|
|
13
|
+
* @returns A fully populated `IntegrationContext` with stubbed methods
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* // Vitest
|
|
18
|
+
* const ctx = createMockIntegrationContext(vi.fn);
|
|
19
|
+
*
|
|
20
|
+
* // Jest
|
|
21
|
+
* const ctx = createMockIntegrationContext(jest.fn);
|
|
22
|
+
*
|
|
23
|
+
* // No framework — plain no-ops
|
|
24
|
+
* const ctx = createMockIntegrationContext();
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
const createMockIntegrationContext = (createMockFn = noOp) => {
|
|
28
|
+
const createCacheScope = () => ({
|
|
29
|
+
get: createMockFn(),
|
|
30
|
+
set: createMockFn(),
|
|
31
|
+
delete: createMockFn()
|
|
32
|
+
});
|
|
33
|
+
const childFn = createMockFn();
|
|
34
|
+
const logger = {
|
|
35
|
+
child: childFn,
|
|
36
|
+
info: createMockFn(),
|
|
37
|
+
debug: createMockFn(),
|
|
38
|
+
trace: createMockFn(),
|
|
39
|
+
warn: createMockFn(),
|
|
40
|
+
error: createMockFn(),
|
|
41
|
+
fatal: createMockFn()
|
|
21
42
|
};
|
|
43
|
+
// Make child() return the logger for method chaining
|
|
44
|
+
if (typeof childFn.mockReturnValue === 'function') {
|
|
45
|
+
childFn.mockReturnValue(logger);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
logger.child = () => logger;
|
|
49
|
+
}
|
|
22
50
|
return {
|
|
23
|
-
cache
|
|
51
|
+
cache: {
|
|
52
|
+
global: createCacheScope(),
|
|
53
|
+
integration: createCacheScope(),
|
|
54
|
+
user: createCacheScope()
|
|
55
|
+
},
|
|
24
56
|
integrationId: 'test-integration',
|
|
25
|
-
userId:
|
|
26
|
-
logger
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
trace: jest.fn(),
|
|
30
|
-
warn: jest.fn(),
|
|
31
|
-
error: jest.fn(),
|
|
32
|
-
fatal: jest.fn()
|
|
33
|
-
}
|
|
57
|
+
userId: 1,
|
|
58
|
+
logger,
|
|
59
|
+
startPolling: createMockFn(),
|
|
60
|
+
stopPolling: createMockFn()
|
|
34
61
|
};
|
|
35
62
|
};
|
|
36
63
|
exports.createMockIntegrationContext = createMockIntegrationContext;
|
|
@@ -14,8 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./test-factory/create-integration-tests"), exports);
|
|
18
17
|
__exportStar(require("./enhanced-utils/create-entity"), exports);
|
|
19
18
|
__exportStar(require("./enhanced-utils/create-mock-integration-context"), exports);
|
|
20
|
-
__exportStar(require("./enhanced-utils/mock-request"), exports);
|
|
21
|
-
__exportStar(require("./enhanced-utils/validate-integration"), exports);
|
package/dist/lib/types.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.IntegrationError = void 0;
|
|
4
|
-
|
|
4
|
+
// Re-export utils-specific types
|
|
5
|
+
var errors_1 = require("./errors");
|
|
5
6
|
Object.defineProperty(exports, "IntegrationError", { enumerable: true, get: function () { return errors_1.IntegrationError; } });
|