modality-kit 0.14.14 → 0.14.16
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/index.js +4 -4
- package/dist/types/index.d.ts +1 -5
- package/dist/types/schemas/jsonrpc.d.ts +4 -4
- package/package.json +11 -7
- package/dist/types/util_tests/TimerMockManager.d.ts +0 -85
- package/dist/types/util_tests/__tests__/console-mock.test.d.ts +0 -1
- package/dist/types/util_tests/console-mock.d.ts +0 -49
- package/dist/types/util_tests/isTestEnvironment.d.ts +0 -1
package/dist/index.js
CHANGED
|
@@ -149,7 +149,10 @@ class ModalityLogger {
|
|
|
149
149
|
return now.toISOString();
|
|
150
150
|
}
|
|
151
151
|
initLogLevel() {
|
|
152
|
-
|
|
152
|
+
let processEnvLogLevel = null;
|
|
153
|
+
if (typeof process !== "undefined") {
|
|
154
|
+
processEnvLogLevel = process.env.MODALITY_LOG_LEVEL;
|
|
155
|
+
}
|
|
153
156
|
this.logLevel = levels.indexOf(processEnvLogLevel) !== -1 ? processEnvLogLevel : "info";
|
|
154
157
|
}
|
|
155
158
|
shouldLog(level) {
|
|
@@ -5696,8 +5699,6 @@ class JSONRPCManager extends JSONRPCCall {
|
|
|
5696
5699
|
this.methods.clear();
|
|
5697
5700
|
}
|
|
5698
5701
|
}
|
|
5699
|
-
// src/util_tests/isTestEnvironment.ts
|
|
5700
|
-
var isTestEnvironment = globalThis.Bun?.main?.includes?.("test");
|
|
5701
5702
|
// src/websocket-client.ts
|
|
5702
5703
|
var logger3 = getLoggerInstance("WebSocket-Client");
|
|
5703
5704
|
|
|
@@ -6026,7 +6027,6 @@ export {
|
|
|
6026
6027
|
withErrorHandling,
|
|
6027
6028
|
mergeResponsesContent,
|
|
6028
6029
|
loadVersion,
|
|
6029
|
-
isTestEnvironment,
|
|
6030
6030
|
getLoggerInstance,
|
|
6031
6031
|
formatSuccessResponse,
|
|
6032
6032
|
formatErrorResponse,
|
package/dist/types/index.d.ts
CHANGED
|
@@ -16,12 +16,8 @@ export { JSONRPCUtils } from "./JSONRPCUtils";
|
|
|
16
16
|
export { JSONRPCManager } from "./jsonrpc-manager";
|
|
17
17
|
export { JSONRPCErrorCode } from "./schemas/jsonrpc";
|
|
18
18
|
export type { JSONRPCManagerEvents, JSONRPCManagerConfig, } from "./jsonrpc-manager";
|
|
19
|
-
export type { JSONRPCMessage, JSONRPCRequest, JSONRPCNotification, JSONRPCResponse, JSONRPCBatchRequest, JSONRPCBatchResponse, JSONRPCErrorResponse, JSONRPCValidationResult, JSONRPCError, JSONRPCParams, CommandExecuteParams, NotificationSendParams, } from "./schemas/jsonrpc";
|
|
19
|
+
export type { JSONRPCMessage, JSONRPCRequest, JSONRPCNotification, JSONRPCResponse, JSONRPCBatchRequest, JSONRPCBatchResponse, JSONRPCErrorResponse, JSONRPCValidationResult, JSONRPCError, JSONRPCParams, JSONRPCId, CommandExecuteParams, NotificationSendParams, } from "./schemas/jsonrpc";
|
|
20
20
|
export { ERROR_METHOD_NOT_FOUND } from "./jsonrpc-manager";
|
|
21
|
-
/**
|
|
22
|
-
* For test tool
|
|
23
|
-
*/
|
|
24
|
-
export { isTestEnvironment } from "./util_tests/isTestEnvironment";
|
|
25
21
|
export { WebSocketClient } from "./websocket-client";
|
|
26
22
|
export { LruCache } from "./lruCache";
|
|
27
23
|
export { SimpleCache } from "./simple-cache";
|
|
@@ -12,6 +12,10 @@
|
|
|
12
12
|
* Or as object: { methodName: JSONRPCMethod<MyParams, MyResult> }
|
|
13
13
|
*/
|
|
14
14
|
export type JSONRPCMethod<TParams = JSONRPCParams, TResult = any> = (method: string, params?: TParams, options?: any) => Promise<TResult>;
|
|
15
|
+
/**
|
|
16
|
+
* JSON-RPC 2.0 ID type - string, number, or null
|
|
17
|
+
*/
|
|
18
|
+
export type JSONRPCId = string | number | null;
|
|
15
19
|
/**
|
|
16
20
|
* JSON-RPC 2.0 Request object
|
|
17
21
|
*/
|
|
@@ -81,10 +85,6 @@ export declare const JSONRPC_VERSION: "2.0";
|
|
|
81
85
|
* See: https://www.jsonrpc.org/specification#parameter_structures
|
|
82
86
|
*/
|
|
83
87
|
export type JSONRPCParams = Record<any, any> | any[] | null;
|
|
84
|
-
/**
|
|
85
|
-
* JSON-RPC 2.0 ID type - string, number, or null
|
|
86
|
-
*/
|
|
87
|
-
export type JSONRPCId = string | number | null;
|
|
88
88
|
/**
|
|
89
89
|
* JSON-RPC 2.0 Error object
|
|
90
90
|
*/
|
package/package.json
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.14.
|
|
2
|
+
"version": "0.14.16",
|
|
3
3
|
"name": "modality-kit",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
|
-
"url": "https://github.com/react-atomic/modality"
|
|
6
|
+
"url": "git+https://github.com/react-atomic/modality.git"
|
|
7
7
|
},
|
|
8
8
|
"homepage": "https://github.com/react-atomic/modality/tree/main/modality-kit",
|
|
9
9
|
"description": "A TypeScript-based toolkit for building web applications and managing communication with a backend server. It provides a set of utilities and components for handling JSON-RPC messages, managing pending operations, and creating reactive web components.",
|
|
10
|
-
"keywords": [
|
|
10
|
+
"keywords": [
|
|
11
|
+
"modality-kit"
|
|
12
|
+
],
|
|
11
13
|
"author": "Hill <hill@kimo.com>",
|
|
12
14
|
"license": "ISC",
|
|
13
15
|
"devDependencies": {
|
|
14
16
|
"@modelcontextprotocol/sdk": "^1.24.2",
|
|
15
|
-
"
|
|
16
|
-
"typescript": "^5.9.2",
|
|
17
|
+
"modality-bun-kit": "^0.0.1",
|
|
17
18
|
"zod": "^3.25.76"
|
|
18
19
|
},
|
|
19
20
|
"exports": {
|
|
@@ -25,7 +26,6 @@
|
|
|
25
26
|
"main": "./dist/index.js",
|
|
26
27
|
"module": "./dist/index.js",
|
|
27
28
|
"scripts": {
|
|
28
|
-
"update-compile-sh": "yo reshow:compile-sh",
|
|
29
29
|
"build:clean": "find ./dist -name '*.*' | xargs rm -rf",
|
|
30
30
|
"build:types": "bun tsc -p ./",
|
|
31
31
|
"build:src": "bun build src/index.ts --outdir dist",
|
|
@@ -34,5 +34,9 @@
|
|
|
34
34
|
"test": "npm run build && bun test",
|
|
35
35
|
"prepublishOnly": "npm t"
|
|
36
36
|
},
|
|
37
|
-
"files": [
|
|
37
|
+
"files": [
|
|
38
|
+
"package.json",
|
|
39
|
+
"README.md",
|
|
40
|
+
"dist"
|
|
41
|
+
]
|
|
38
42
|
}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Timer Mock Utilities
|
|
3
|
-
*
|
|
4
|
-
* These utilities provide centralized timer mocking for tests that need to control time.
|
|
5
|
-
* This ensures consistent behavior across all tests that use setTimeout, setInterval, etc.
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Centralized timer mock manager for controlling time in tests
|
|
9
|
-
*
|
|
10
|
-
* Features:
|
|
11
|
-
* - Mock setTimeout with virtual clock advancement
|
|
12
|
-
* - Mock Math.random for deterministic jitter elimination
|
|
13
|
-
* - Track virtual time progression
|
|
14
|
-
* - Immediate callback execution for fast tests
|
|
15
|
-
*
|
|
16
|
-
* Usage:
|
|
17
|
-
* ```typescript
|
|
18
|
-
* import { TimerMockManager } from "../util_tests/TimerMockManager.js";
|
|
19
|
-
*
|
|
20
|
-
* let timerMock: TimerMockManager;
|
|
21
|
-
*
|
|
22
|
-
* beforeEach(() => {
|
|
23
|
-
* timerMock = new TimerMockManager();
|
|
24
|
-
* timerMock.setup();
|
|
25
|
-
* });
|
|
26
|
-
*
|
|
27
|
-
* afterEach(() => {
|
|
28
|
-
* timerMock.restore();
|
|
29
|
-
* });
|
|
30
|
-
* ```
|
|
31
|
-
*/
|
|
32
|
-
export declare class TimerMockManager {
|
|
33
|
-
private originalSetTimeout?;
|
|
34
|
-
private originalClearTimeout?;
|
|
35
|
-
private originalMathRandom?;
|
|
36
|
-
private mockSetTimeout?;
|
|
37
|
-
private mockClearTimeout?;
|
|
38
|
-
private activeTimers;
|
|
39
|
-
private timerIdCounter;
|
|
40
|
-
private virtualClock;
|
|
41
|
-
private isDestroyed;
|
|
42
|
-
private suppressTimeouts;
|
|
43
|
-
/**
|
|
44
|
-
* Setup timer mocks
|
|
45
|
-
* @param executeImmediately - Whether to execute callbacks immediately (default: true for fast tests)
|
|
46
|
-
* @param mockRandomValue - Fixed value for Math.random (default: 0 to eliminate jitter)
|
|
47
|
-
*/
|
|
48
|
-
setup(executeImmediately?: boolean, mockRandomValue?: number): void;
|
|
49
|
-
/**
|
|
50
|
-
* Restore original timer functions
|
|
51
|
-
*/
|
|
52
|
-
restore(): void;
|
|
53
|
-
/**
|
|
54
|
-
* Get the current virtual clock time
|
|
55
|
-
*/
|
|
56
|
-
getVirtualClock(): number;
|
|
57
|
-
/**
|
|
58
|
-
* Reset virtual clock to zero
|
|
59
|
-
*/
|
|
60
|
-
resetClock(): void;
|
|
61
|
-
/**
|
|
62
|
-
* Get the mock setTimeout function for assertions
|
|
63
|
-
*/
|
|
64
|
-
getMockSetTimeout(): any;
|
|
65
|
-
/**
|
|
66
|
-
* Clear all active timers
|
|
67
|
-
*/
|
|
68
|
-
clearAllActiveTimers(): void;
|
|
69
|
-
/**
|
|
70
|
-
* Get the number of active timers
|
|
71
|
-
*/
|
|
72
|
-
getActiveTimerCount(): number;
|
|
73
|
-
/**
|
|
74
|
-
* Suppress timeout execution temporarily
|
|
75
|
-
*/
|
|
76
|
-
suppressTimeoutExecution(): void;
|
|
77
|
-
/**
|
|
78
|
-
* Resume timeout execution
|
|
79
|
-
*/
|
|
80
|
-
resumeTimeoutExecution(): void;
|
|
81
|
-
/**
|
|
82
|
-
* Verify that setTimeout was called with expected parameters
|
|
83
|
-
*/
|
|
84
|
-
expectSetTimeoutCalled(times: number, delay?: number): void;
|
|
85
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Console Mock Utility
|
|
3
|
-
*
|
|
4
|
-
* Provides utilities for mocking console output during testing to keep test output clean.
|
|
5
|
-
* Can be used across multiple test files for consistent console mocking.
|
|
6
|
-
*/
|
|
7
|
-
export declare class ConsoleMock {
|
|
8
|
-
private originalMethods;
|
|
9
|
-
private isMocked;
|
|
10
|
-
/**
|
|
11
|
-
* Mock all console methods to prevent output during tests
|
|
12
|
-
*/
|
|
13
|
-
mock(): void;
|
|
14
|
-
/**
|
|
15
|
-
* Restore original console methods
|
|
16
|
-
*/
|
|
17
|
-
restore(): void;
|
|
18
|
-
/**
|
|
19
|
-
* Check if console is currently mocked
|
|
20
|
-
*/
|
|
21
|
-
get isActive(): boolean;
|
|
22
|
-
/**
|
|
23
|
-
* Temporarily restore console methods for debugging purposes
|
|
24
|
-
* Returns a function to re-mock console methods
|
|
25
|
-
*/
|
|
26
|
-
temporaryRestore(): () => void;
|
|
27
|
-
}
|
|
28
|
-
export declare const consoleMock: ConsoleMock;
|
|
29
|
-
/**
|
|
30
|
-
* Convenience functions for common usage patterns
|
|
31
|
-
*/
|
|
32
|
-
/**
|
|
33
|
-
* Setup console mocking for a test suite (use in beforeAll)
|
|
34
|
-
*/
|
|
35
|
-
export declare function setupConsoleMock(): void;
|
|
36
|
-
/**
|
|
37
|
-
* Cleanup console mocking for a test suite (use in afterAll)
|
|
38
|
-
*/
|
|
39
|
-
export declare function cleanupConsoleMock(): void;
|
|
40
|
-
/**
|
|
41
|
-
* Higher-order function to run a function with console temporarily restored
|
|
42
|
-
* Useful for debugging specific tests
|
|
43
|
-
*/
|
|
44
|
-
export declare function withConsole<T>(fn: () => T): T;
|
|
45
|
-
/**
|
|
46
|
-
* Higher-order function to run an async function with console temporarily restored
|
|
47
|
-
* Useful for debugging specific async tests
|
|
48
|
-
*/
|
|
49
|
-
export declare function withConsoleAsync<T>(fn: () => Promise<T>): Promise<T>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const isTestEnvironment: boolean;
|