turn-based-mcp-shared 1.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 (111) hide show
  1. package/dist/constants/game-constants.d.ts +77 -0
  2. package/dist/constants/game-constants.d.ts.map +1 -0
  3. package/dist/constants/game-constants.js +68 -0
  4. package/dist/constants/game-constants.js.map +1 -0
  5. package/dist/constants/index.d.ts +5 -0
  6. package/dist/constants/index.d.ts.map +1 -0
  7. package/dist/constants/index.js +5 -0
  8. package/dist/constants/index.js.map +1 -0
  9. package/dist/games/index.d.ts +3 -0
  10. package/dist/games/index.d.ts.map +1 -0
  11. package/dist/games/index.js +3 -0
  12. package/dist/games/index.js.map +1 -0
  13. package/dist/games/rock-paper-scissors.d.ts +117 -0
  14. package/dist/games/rock-paper-scissors.d.ts.map +1 -0
  15. package/dist/games/rock-paper-scissors.js +247 -0
  16. package/dist/games/rock-paper-scissors.js.map +1 -0
  17. package/dist/games/tic-tac-toe.d.ts +121 -0
  18. package/dist/games/tic-tac-toe.d.ts.map +1 -0
  19. package/dist/games/tic-tac-toe.js +240 -0
  20. package/dist/games/tic-tac-toe.js.map +1 -0
  21. package/dist/index.d.ts +7 -0
  22. package/dist/index.d.ts.map +1 -0
  23. package/dist/index.js +5 -0
  24. package/dist/index.js.map +1 -0
  25. package/dist/storage/game-storage.d.ts +11 -0
  26. package/dist/storage/game-storage.d.ts.map +1 -0
  27. package/dist/storage/game-storage.js +28 -0
  28. package/dist/storage/game-storage.js.map +1 -0
  29. package/dist/storage/index.d.ts +3 -0
  30. package/dist/storage/index.d.ts.map +1 -0
  31. package/dist/storage/index.js +3 -0
  32. package/dist/storage/index.js.map +1 -0
  33. package/dist/storage/mcp-api-client.d.ts +8 -0
  34. package/dist/storage/mcp-api-client.d.ts.map +1 -0
  35. package/dist/storage/mcp-api-client.js +52 -0
  36. package/dist/storage/mcp-api-client.js.map +1 -0
  37. package/dist/storage/memory-storage.d.ts +12 -0
  38. package/dist/storage/memory-storage.d.ts.map +1 -0
  39. package/dist/storage/memory-storage.js +34 -0
  40. package/dist/storage/memory-storage.js.map +1 -0
  41. package/dist/storage/sqlite-storage.d.ts +2 -0
  42. package/dist/storage/sqlite-storage.d.ts.map +1 -0
  43. package/dist/storage/sqlite-storage.js +3 -0
  44. package/dist/storage/sqlite-storage.js.map +1 -0
  45. package/dist/testing/api-test-utils.d.ts +56 -0
  46. package/dist/testing/api-test-utils.d.ts.map +1 -0
  47. package/dist/testing/api-test-utils.js +125 -0
  48. package/dist/testing/api-test-utils.js.map +1 -0
  49. package/dist/testing/index.d.ts +10 -0
  50. package/dist/testing/index.d.ts.map +1 -0
  51. package/dist/testing/index.js +10 -0
  52. package/dist/testing/index.js.map +1 -0
  53. package/dist/testing/test-database.d.ts +24 -0
  54. package/dist/testing/test-database.d.ts.map +1 -0
  55. package/dist/testing/test-database.js +39 -0
  56. package/dist/testing/test-database.js.map +1 -0
  57. package/dist/testing/vitest-setup.d.ts +12 -0
  58. package/dist/testing/vitest-setup.d.ts.map +1 -0
  59. package/dist/testing/vitest-setup.js +35 -0
  60. package/dist/testing/vitest-setup.js.map +1 -0
  61. package/dist/types/game.d.ts +39 -0
  62. package/dist/types/game.d.ts.map +1 -0
  63. package/dist/types/game.js +2 -0
  64. package/dist/types/game.js.map +1 -0
  65. package/dist/types/games.d.ts +26 -0
  66. package/dist/types/games.d.ts.map +1 -0
  67. package/dist/types/games.js +2 -0
  68. package/dist/types/games.js.map +1 -0
  69. package/dist/utils/http-client.d.ts +25 -0
  70. package/dist/utils/http-client.d.ts.map +1 -0
  71. package/dist/utils/http-client.js +42 -0
  72. package/dist/utils/http-client.js.map +1 -0
  73. package/dist/utils/index.d.ts +15 -0
  74. package/dist/utils/index.d.ts.map +1 -0
  75. package/dist/utils/index.js +34 -0
  76. package/dist/utils/index.js.map +1 -0
  77. package/eslint.config.js +41 -0
  78. package/package.json +1 -0
  79. package/src/constants/game-constants.test.ts +102 -0
  80. package/src/constants/game-constants.ts +86 -0
  81. package/src/constants/index.ts +5 -0
  82. package/src/games/index.test.ts +22 -0
  83. package/src/games/index.ts +2 -0
  84. package/src/games/rock-paper-scissors.test.ts +313 -0
  85. package/src/games/rock-paper-scissors.ts +276 -0
  86. package/src/games/tic-tac-toe.test.ts +258 -0
  87. package/src/games/tic-tac-toe.ts +267 -0
  88. package/src/index.test.ts +64 -0
  89. package/src/index.ts +6 -0
  90. package/src/storage/game-storage.test.ts +204 -0
  91. package/src/storage/game-storage.ts +38 -0
  92. package/src/storage/index.test.ts +48 -0
  93. package/src/storage/index.ts +2 -0
  94. package/src/storage/mcp-api-client.test.ts +339 -0
  95. package/src/storage/mcp-api-client.ts +53 -0
  96. package/src/storage/memory-storage.ts +46 -0
  97. package/src/storage/sqlite-storage.test.ts +139 -0
  98. package/src/storage/sqlite-storage.ts +12 -0
  99. package/src/testing/api-test-utils.ts +144 -0
  100. package/src/testing/index.ts +29 -0
  101. package/src/testing/test-database.ts +46 -0
  102. package/src/testing/vitest-setup.ts +35 -0
  103. package/src/types/game.ts +48 -0
  104. package/src/types/games.ts +33 -0
  105. package/src/utils/http-client.ts +44 -0
  106. package/src/utils/index.test.ts +133 -0
  107. package/src/utils/index.ts +40 -0
  108. package/tsconfig-paths.json +12 -0
  109. package/tsconfig.json +19 -0
  110. package/vitest.config.ts +21 -0
  111. package/vitest.setup.ts +10 -0
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Shared API Test Utilities
3
+ *
4
+ * Provides reusable mock factories and test utilities for API route testing
5
+ * to eliminate duplication across test files.
6
+ */
7
+ import { vi } from 'vitest';
8
+ import type { GameSession, Player, BaseGameState, GameType } from '../types/game.js';
9
+ import type { TicTacToeGameState, RPSGameState, TicTacToeMove, RPSMove } from '../types/games.js';
10
+ /**
11
+ * Generic game mock factory
12
+ * Creates a mock game instance with all required methods
13
+ */
14
+ export declare function createGameMock(): {
15
+ getInitialState: ReturnType<typeof vi.fn>;
16
+ validateMove: ReturnType<typeof vi.fn>;
17
+ applyMove: ReturnType<typeof vi.fn>;
18
+ checkGameEnd: ReturnType<typeof vi.fn>;
19
+ getValidMoves: ReturnType<typeof vi.fn>;
20
+ };
21
+ /**
22
+ * Create mock players for testing
23
+ */
24
+ export declare function createMockPlayers(): Player[];
25
+ /**
26
+ * Create a mock TicTacToe game state
27
+ */
28
+ export declare function createMockTicTacToeGameState(overrides?: Partial<TicTacToeGameState>): TicTacToeGameState;
29
+ /**
30
+ * Create a mock Rock Paper Scissors game state
31
+ */
32
+ export declare function createMockRPSGameState(overrides?: Partial<RPSGameState>): RPSGameState;
33
+ /**
34
+ * Create a mock game session
35
+ */
36
+ export declare function createMockGameSession<T extends BaseGameState>(gameState: T, gameType: GameType): GameSession<T>;
37
+ /**
38
+ * Vitest mock configuration for shared package games
39
+ * Use this to create consistent mocks across API route tests
40
+ */
41
+ export declare function createSharedGameMocks(gameClass: string): {
42
+ mockImplementation: () => Promise<Record<string, unknown>>;
43
+ mockGame: ReturnType<typeof createGameMock>;
44
+ };
45
+ /**
46
+ * Create storage function mocks for a specific game type
47
+ */
48
+ export declare function createStorageMocks(gameType: GameType): Record<string, ReturnType<typeof vi.fn>>;
49
+ /**
50
+ * Standard test moves for different games
51
+ */
52
+ export declare const TEST_MOVES: {
53
+ ticTacToe: TicTacToeMove;
54
+ rockPaperScissors: RPSMove;
55
+ };
56
+ //# sourceMappingURL=api-test-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-test-utils.d.ts","sourceRoot":"","sources":["../../src/testing/api-test-utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAC3B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACjF,OAAO,KAAK,EAAE,kBAAkB,EAAE,YAAY,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAE9F;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125 @@
1
+ /**
2
+ * Shared API Test Utilities
3
+ *
4
+ * Provides reusable mock factories and test utilities for API route testing
5
+ * to eliminate duplication across test files.
6
+ */
7
+ import { vi } from 'vitest';
8
+ /**
9
+ * Generic game mock factory
10
+ * Creates a mock game instance with all required methods
11
+ */
12
+ export function createGameMock() {
13
+ return {
14
+ getInitialState: vi.fn(),
15
+ validateMove: vi.fn(),
16
+ applyMove: vi.fn(),
17
+ checkGameEnd: vi.fn(),
18
+ getValidMoves: vi.fn()
19
+ };
20
+ }
21
+ /**
22
+ * Create mock players for testing
23
+ */
24
+ export function createMockPlayers() {
25
+ return [
26
+ { id: 'player1', name: 'Player', isAI: false },
27
+ { id: 'ai', name: 'AI', isAI: true }
28
+ ];
29
+ }
30
+ /**
31
+ * Create a mock TicTacToe game state
32
+ */
33
+ export function createMockTicTacToeGameState(overrides = {}) {
34
+ return {
35
+ id: 'test-game-1',
36
+ players: createMockPlayers(),
37
+ currentPlayerId: 'player1',
38
+ status: 'playing',
39
+ createdAt: new Date('2024-01-01T10:00:00Z'),
40
+ updatedAt: new Date('2024-01-01T10:00:00Z'),
41
+ board: [
42
+ [null, null, null],
43
+ [null, null, null],
44
+ [null, null, null]
45
+ ],
46
+ playerSymbols: {
47
+ player1: 'X',
48
+ ai: 'O'
49
+ },
50
+ ...overrides
51
+ };
52
+ }
53
+ /**
54
+ * Create a mock Rock Paper Scissors game state
55
+ */
56
+ export function createMockRPSGameState(overrides = {}) {
57
+ return {
58
+ id: 'test-rps-1',
59
+ players: createMockPlayers(),
60
+ currentPlayerId: 'player1',
61
+ status: 'playing',
62
+ createdAt: new Date('2024-01-01T10:00:00Z'),
63
+ updatedAt: new Date('2024-01-01T10:00:00Z'),
64
+ rounds: [],
65
+ currentRound: 0,
66
+ maxRounds: 3,
67
+ scores: {
68
+ player1: 0,
69
+ ai: 0
70
+ },
71
+ ...overrides
72
+ };
73
+ }
74
+ /**
75
+ * Create a mock game session
76
+ */
77
+ export function createMockGameSession(gameState, gameType) {
78
+ return {
79
+ gameState,
80
+ gameType,
81
+ history: [],
82
+ difficulty: 'medium'
83
+ };
84
+ }
85
+ /**
86
+ * Vitest mock configuration for shared package games
87
+ * Use this to create consistent mocks across API route tests
88
+ */
89
+ export function createSharedGameMocks(gameClass) {
90
+ const mockGame = createGameMock();
91
+ return {
92
+ mockImplementation: async () => ({
93
+ ...await vi.importActual('@turn-based-mcp/shared/constants'),
94
+ [gameClass]: vi.fn().mockImplementation(() => mockGame)
95
+ }),
96
+ mockGame
97
+ };
98
+ }
99
+ /**
100
+ * Create storage function mocks for a specific game type
101
+ */
102
+ export function createStorageMocks(gameType) {
103
+ if (gameType === 'tic-tac-toe') {
104
+ return {
105
+ getTicTacToeGame: vi.fn(),
106
+ setTicTacToeGame: vi.fn(),
107
+ getAllTicTacToeGames: vi.fn()
108
+ };
109
+ }
110
+ else {
111
+ return {
112
+ getRPSGame: vi.fn(),
113
+ setRPSGame: vi.fn(),
114
+ getAllRPSGames: vi.fn()
115
+ };
116
+ }
117
+ }
118
+ /**
119
+ * Standard test moves for different games
120
+ */
121
+ export const TEST_MOVES = {
122
+ ticTacToe: { row: 0, col: 0 },
123
+ rockPaperScissors: { choice: 'rock' }
124
+ };
125
+ //# sourceMappingURL=api-test-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-test-utils.js","sourceRoot":"","sources":["../../src/testing/api-test-utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAI3B;;;GAGG;AACH,MAAM,UAAU,cAAc;IAO5B,OAAO;QACL,eAAe,EAAE,EAAE,CAAC,EAAE,EAAE;QACxB,YAAY,EAAE,EAAE,CAAC,EAAE,EAAE;QACrB,SAAS,EAAE,EAAE,CAAC,EAAE,EAAE;QAClB,YAAY,EAAE,EAAE,CAAC,EAAE,EAAE;QACrB,aAAa,EAAE,EAAE,CAAC,EAAE,EAAE;KACvB,CAAA;AACH,CAAC;A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turn-based games platform
3
+ *
4
+ * This module exports centralized testing utilities that can be used
5
+ * across all packages in the monorepo for consistent test setup.
6
+ */
7
+ export { setupTestDatabase, teardownTestDatabase, clearTestDatabase, getTestDatabase, isTestDatabaseReady } from './test-database.js';
8
+ export { createGameMock, createMockPlayers, createMockTicTacToeGameState, createMockRPSGameState, createMockGameSession, createSharedGameMocks, createStorageMocks, TEST_MOVES } from './api-test-utils.js';
9
+ export { setupStandardTestDatabase } from './vitest-setup.js';
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,EACjB,eAAe,EACf,mBAAmB,EACpB,MAAM,iBAAiB,CAAA;AAExB,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,4BAA4B,EAC5B,sBAAsB,EACtB,qBAAqB,EACrB,qBAAqB,EACrB,kBAAkB,EAClB,UAAU,EACX,MAAM,kBAAkB,CAAA;AAEzB,OAAO,EACL,yBAAyB,EAC1B,MAAM,gBAAgB,CAAA"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Testing utilities for the turn-based games platform
3
+ *
4
+ * This module exports centralized testing utilities that can be used
5
+ * across all packages in the monorepo for consistent test setup.
6
+ */
7
+ export { setupTestDatabase, teardownTestDatabase, clearTestDatabase, getTestDatabase, isTestDatabaseReady } from './test-database.js';
8
+ export { createGameMock, createMockPlayers, createMockTicTacToeGameState, createMockRPSGameState, createMockGameSession, createSharedGameMocks, createStorageMocks, TEST_MOVES } from './api-test-utils.js';
9
+ export { setupStandardTestDatabase } from './vitest-setup.js';
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,EACjB,eAAe,EACf,mBAAmB,EACpB,MAAM,iBAAiB,CAAA;AAExB,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,4BAA4B,EAC5B,sBAAsB,EACtB,qBAAqB,EACrB,qBAAqB,EACrB,kBAAkB,EAClB,UAAU,EACX,MAAM,kBAAkB,CAAA;AAEzB,OAAO,EACL,yBAAyB,EAC1B,MAAM,gBAAgB,CAAA"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Sets up a test database with clean state
3
+ * Uses in-memory storage, so setup is a no-op
4
+ */
5
+ export declare function setupTestDatabase(useMemory?: boolean, testName?: string): Promise<void>;
6
+ /**
7
+ * Cleans up the test database
8
+ * Uses in-memory storage, so teardown is a no-op
9
+ */
10
+ export declare function teardownTestDatabase(): Promise<void>;
11
+ /**
12
+ * Clears all data from test database tables
13
+ */
14
+ export declare function clearTestDatabase(): Promise<void>;
15
+ /**
16
+ * Gets the current test database instance
17
+ * Returns null for in-memory storage
18
+ */
19
+ export declare function getTestDatabase(): null;
20
+ /**
21
+ * Utility function for tests that need to check if database is ready
22
+ */
23
+ export declare function isTestDatabaseReady(): boolean;
24
+ //# sourceMappingURL=test-database.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-database.d.ts","sourceRoot":"","sources":["../../src/testing/test-database.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,wBAAsB,iBAAiB,CACrC,SAAS,GAAE,OAAc,EACzB,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,IAAI,CAAC,CAIf;AAED;;;GAGG;AACH,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC,CAG1D;AAED;;GAEG;AACH,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,CAEvD;AAED;;;GAGG;AACH,wBAAgB,eAAe,IAAI,IAAI,CAEtC;AAED;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,OAAO,CAE7C"}
@@ -0,0 +1,39 @@
1
+ // Mock test database utilities for in-memory storage
2
+ import { resetDatabaseInstance } from '../storage/sqlite-storage.js';
3
+ /**
4
+ * Sets up a test database with clean state
5
+ * Uses in-memory storage, so setup is a no-op
6
+ */
7
+ export async function setupTestDatabase(useMemory = true, testName) {
8
+ // In-memory storage doesn't need setup
9
+ // Just clear any existing data
10
+ await resetDatabaseInstance();
11
+ }
12
+ /**
13
+ * Cleans up the test database
14
+ * Uses in-memory storage, so teardown is a no-op
15
+ */
16
+ export async function teardownTestDatabase() {
17
+ // In-memory storage doesn't need teardown
18
+ await resetDatabaseInstance();
19
+ }
20
+ /**
21
+ * Clears all data from test database tables
22
+ */
23
+ export async function clearTestDatabase() {
24
+ await resetDatabaseInstance();
25
+ }
26
+ /**
27
+ * Gets the current test database instance
28
+ * Returns null for in-memory storage
29
+ */
30
+ export function getTestDatabase() {
31
+ return null;
32
+ }
33
+ /**
34
+ * Utility function for tests that need to check if database is ready
35
+ */
36
+ export function isTestDatabaseReady() {
37
+ return true;
38
+ }
39
+ //# sourceMappingURL=test-database.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-database.js","sourceRoot":"","sources":["../../src/testing/test-database.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAA;AAEpE;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,YAAqB,IAAI,EACzB,QAAiB;IAEjB,uCAAuC;IACvC,+BAA+B;IAC/B,MAAM,qBAAqB,EAAE,CAAA;AAC/B,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB;IACxC,0CAA0C;IAC1C,MAAM,qBAAqB,EAAE,CAAA;AAC/B,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB;IACrC,MAAM,qBAAqB,EAAE,CAAA;AAC/B,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,eAAe;IAC7B,OAAO,IAAI,CAAA;AACb,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB;IACjC,OAAO,IAAI,CAAA;AACb,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Shared Vitest Setup Functions
3
+ *
4
+ * Provides standardized test setup and teardown functions to reduce
5
+ * duplication across package vitest setup files.
6
+ */
7
+ /**
8
+ * Standard database setup for all packages
9
+ * Call this in vitest.setup.ts files to ensure consistent database setup
10
+ */
11
+ export declare function setupStandardTestDatabase(): void;
12
+ //# sourceMappingURL=vitest-setup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vitest-setup.d.ts","sourceRoot":"","sources":["../../src/testing/vitest-setup.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH;;;GAGG;AACH,wBAAgB,yBAAyB,IAAI,IAAI,CAoBhD"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Shared Vitest Setup Functions
3
+ *
4
+ * Provides standardized test setup and teardown functions to reduce
5
+ * duplication across package vitest setup files.
6
+ */
7
+ import { beforeAll, afterAll } from 'vitest';
8
+ import { setupTestDatabase, teardownTestDatabase } from './test-database.js';
9
+ /**
10
+ * Standard database setup for all packages
11
+ * Call this in vitest.setup.ts files to ensure consistent database setup
12
+ */
13
+ export function setupStandardTestDatabase() {
14
+ // Setup test database before all tests
15
+ beforeAll(async () => {
16
+ try {
17
+ await setupTestDatabase(true); // Use in-memory database for speed
18
+ }
19
+ catch (error) {
20
+ console.error('Failed to setup test database:', error);
21
+ throw error;
22
+ }
23
+ });
24
+ // Cleanup test database after all tests
25
+ afterAll(async () => {
26
+ try {
27
+ await teardownTestDatabase();
28
+ }
29
+ catch (error) {
30
+ console.error('Failed to teardown test database:', error);
31
+ // Don't throw here to avoid masking other test failures
32
+ }
33
+ });
34
+ }
35
+ //# sourceMappingURL=vitest-setup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vitest-setup.js","sourceRoot":"","sources":["../../src/testing/vitest-setup.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAC5C,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AAEzE;;;GAGG;AACH,MAAM,UAAU,yBAAyB;IACvC,uCAAuC;IACvC,SAAS,CAAC,KAAK,IAAI,EAAE;QACnB,IAAI,CAAC;YACH,MAAM,iBAAiB,CAAC,IAAI,CAAC,CAAA,CAAC,mCAAmC;QACnE,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,gCAAgC,EAAE,KAAK,CAAC,CAAA;YACtD,MAAM,KAAK,CAAA;QACb,CAAC;IACH,CAAC,CAAC,CAAA;IAEF,wCAAwC;IACxC,QAAQ,CAAC,KAAK,IAAI,EAAE;QAClB,IAAI,CAAC;YACH,MAAM,oBAAoB,EAAE,CAAA;QAC9B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,mCAAmC,EAAE,KAAK,CAAC,CAAA;YACzD,wDAAwD;QAC1D,CAAC;IACH,CAAC,CAAC,CAAA;AACJ,CAAC"}
@@ -0,0 +1,39 @@
1
+ import type { PlayerId, GameStatus, GameType, Difficulty } from '../constants/game-constants.js';
2
+ export type { PlayerId, GameStatus, GameType, Difficulty };
3
+ export interface Player {
4
+ id: PlayerId;
5
+ name: string;
6
+ isAI: boolean;
7
+ }
8
+ export interface BaseGameState {
9
+ id: string;
10
+ players: Player[];
11
+ currentPlayerId: PlayerId;
12
+ status: GameStatus;
13
+ winner?: PlayerId | 'draw';
14
+ createdAt: Date;
15
+ updatedAt: Date;
16
+ }
17
+ export interface GameMove<T = unknown> {
18
+ playerId: PlayerId;
19
+ move: T;
20
+ timestamp: Date;
21
+ }
22
+ export interface GameResult {
23
+ winner?: PlayerId | 'draw';
24
+ reason: string;
25
+ }
26
+ export interface Game<TGameState extends BaseGameState, TMove> {
27
+ validateMove(gameState: TGameState, move: TMove, playerId: PlayerId): boolean;
28
+ applyMove(gameState: TGameState, move: TMove, playerId: PlayerId): TGameState;
29
+ checkGameEnd(gameState: TGameState): GameResult | null;
30
+ getValidMoves(gameState: TGameState, playerId: PlayerId): TMove[];
31
+ getInitialState(players: Player[], options?: Record<string, unknown>): TGameState;
32
+ }
33
+ export interface GameSession<TGameState extends BaseGameState = BaseGameState> {
34
+ gameState: TGameState;
35
+ gameType: GameType;
36
+ history: GameMove[];
37
+ difficulty?: Difficulty;
38
+ }
39
+ //# sourceMappingURL=game.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"game.d.ts","sourceRoot":"","sources":["../../src/types/game.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AAE7F,YAAY,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAA;AAE1D,MAAM,WAAW,MAAM;IACrB,EAAE,EAAE,QAAQ,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,OAAO,CAAC;CACf;AAED,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,eAAe,EAAE,QAAQ,CAAC;IAC1B,MAAM,EAAE,UAAU,CAAC;IACnB,MAAM,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAC;IAC3B,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;CACjB;AAED,MAAM,WAAW,QAAQ,CAAC,CAAC,GAAG,OAAO;IACnC,QAAQ,EAAE,QAAQ,CAAC;IACnB,IAAI,EAAE,CAAC,CAAC;IACR,SAAS,EAAE,IAAI,CAAC;CACjB;AAED,MAAM,WAAW,UAAU;IACzB,MAAM,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC;CAChB;AAGD,MAAM,WAAW,IAAI,CAAC,UAAU,SAAS,aAAa,EAAE,KAAK;IAC3D,YAAY,CAAC,SAAS,EAAE,UAAU,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC;IAC9E,SAAS,CAAC,SAAS,EAAE,UAAU,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,GAAG,UAAU,CAAC;IAC9E,YAAY,CAAC,SAAS,EAAE,UAAU,GAAG,UAAU,GAAG,IAAI,CAAC;IACvD,aAAa,CAAC,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,GAAG,KAAK,EAAE,CAAC;IAClE,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,UAAU,CAAC;CACnF;AAGD,MAAM,WAAW,WAAW,CAAC,UAAU,SAAS,aAAa,GAAG,aAAa;IAC3E,SAAS,EAAE,UAAU,CAAC;IACtB,QAAQ,EAAE,QAAQ,CAAC;IACnB,OAAO,EAAE,QAAQ,EAAE,CAAC;IACpB,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=game.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"game.js","sourceRoot":"","sources":["../../src/types/game.ts"],"names":[],"mappings":""}
@@ -0,0 +1,26 @@
1
+ import { BaseGameState } from './game.js';
2
+ export type CellValue = 'X' | 'O' | null;
3
+ export type Board = CellValue[][];
4
+ export interface TicTacToeMove {
5
+ row: number;
6
+ col: number;
7
+ }
8
+ export interface TicTacToeGameState extends BaseGameState {
9
+ board: Board;
10
+ playerSymbols: Record<string, 'X' | 'O'>;
11
+ }
12
+ export type RPSChoice = 'rock' | 'paper' | 'scissors';
13
+ export interface RPSMove {
14
+ choice: RPSChoice;
15
+ }
16
+ export interface RPSGameState extends BaseGameState {
17
+ rounds: Array<{
18
+ player1Choice?: RPSChoice;
19
+ player2Choice?: RPSChoice;
20
+ winner?: string | 'draw';
21
+ }>;
22
+ currentRound: number;
23
+ maxRounds: number;
24
+ scores: Record<string, number>;
25
+ }
26
+ //# sourceMappingURL=games.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"games.d.ts","sourceRoot":"","sources":["../../src/types/games.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAGvC,MAAM,MAAM,SAAS,GAAG,GAAG,GAAG,GAAG,GAAG,IAAI,CAAC;AACzC,MAAM,MAAM,KAAK,GAAG,SAAS,EAAE,EAAE,CAAC;AAElC,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,kBAAmB,SAAQ,aAAa;IACvD,KAAK,EAAE,KAAK,CAAC;IACb,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,GAAG,GAAG,CAAC,CAAC;CAC1C;AAGD,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,OAAO,GAAG,UAAU,CAAC;AAEtD,MAAM,WAAW,OAAO;IACtB,MAAM,EAAE,SAAS,CAAC;CACnB;AAED,MAAM,WAAW,YAAa,SAAQ,aAAa;IACjD,MAAM,EAAE,KAAK,CAAC;QACZ,aAAa,CAAC,EAAE,SAAS,CAAC;QAC1B,aAAa,CAAC,EAAE,SAAS,CAAC;QAC1B,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;KAC1B,CAAC,CAAC;IACH,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAChC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=games.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"games.js","sourceRoot":"","sources":["../../src/types/games.ts"],"names":[],"mappings":""}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Shared HTTP client utilities for communicating with the web API
3
+ *
4
+ * Provides centralized HTTP functions to eliminate duplication between
5
+ * the MCP server and shared library API clients.
6
+ */
7
+ export declare const WEB_API_BASE: string;
8
+ /**
9
+ * Performs an HTTP GET request
10
+ *
11
+ * @param url - The URL to fetch from
12
+ * @returns Promise resolving to the JSON response
13
+ * @throws Error if the request fails or returns non-2xx status
14
+ */
15
+ export declare function httpGet<T = unknown>(url: string): Promise<T>;
16
+ /**
17
+ * Performs an HTTP POST request with JSON data
18
+ *
19
+ * @param url - The URL to post to
20
+ * @param data - The data to send in the request body
21
+ * @returns Promise resolving to the JSON response
22
+ * @throws Error if the request fails or returns non-2xx status
23
+ */
24
+ export declare function httpPost<T = unknown>(url: string, data: unknown): Promise<T>;
25
+ //# sourceMappingURL=http-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-client.d.ts","sourceRoot":"","sources":["../../src/utils/http-client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,eAAO,MAAM,YAAY,QAAsD,CAAA;AAE/E;;;;;;GAMG;AACH,wBAAsB,OAAO,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAMlE;AAED;;;;;;;GAOG;AACH,wBAAsB,QAAQ,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,CAUlF"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Shared HTTP client utilities for communicating with the web API
3
+ *
4
+ * Provides centralized HTTP functions to eliminate duplication between
5
+ * the MCP server and shared library API clients.
6
+ */
7
+ // Web app base URL for API calls (configurable via environment)
8
+ export const WEB_API_BASE = process.env.WEB_API_BASE || 'http://localhost:3000';
9
+ /**
10
+ * Performs an HTTP GET request
11
+ *
12
+ * @param url - The URL to fetch from
13
+ * @returns Promise resolving to the JSON response
14
+ * @throws Error if the request fails or returns non-2xx status
15
+ */
16
+ export async function httpGet(url) {
17
+ const response = await fetch(url);
18
+ if (!response.ok) {
19
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`);
20
+ }
21
+ return response.json();
22
+ }
23
+ /**
24
+ * Performs an HTTP POST request with JSON data
25
+ *
26
+ * @param url - The URL to post to
27
+ * @param data - The data to send in the request body
28
+ * @returns Promise resolving to the JSON response
29
+ * @throws Error if the request fails or returns non-2xx status
30
+ */
31
+ export async function httpPost(url, data) {
32
+ const response = await fetch(url, {
33
+ method: 'POST',
34
+ headers: { 'Content-Type': 'application/json' },
35
+ body: JSON.stringify(data)
36
+ });
37
+ if (!response.ok) {
38
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`);
39
+ }
40
+ return response.json();
41
+ }
42
+ //# sourceMappingURL=http-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-client.js","sourceRoot":"","sources":["../../src/utils/http-client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,gEAAgE;AAChE,MAAM,CAAC,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,uBAAuB,CAAA;AAE/E;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO,CAAc,GAAW;IACpD,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,CAAA;IACjC,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,QAAQ,QAAQ,CAAC,MAAM,KAAK,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAA;IACpE,CAAC;IACD,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAA;AACxB,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAc,GAAW,EAAE,IAAa;IACpE,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;QAChC,MAAM,EAAE,MAAM;QACd,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;QAC/C,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;KAC3B,CAAC,CAAA;IACF,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,QAAQ,QAAQ,CAAC,MAAM,KAAK,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAA;IACpE,CAAC;IACD,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAA;AACxB,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { GameType } from '../types/game.js';
2
+ /**
3
+ * Generate a unique game ID
4
+ */
5
+ export declare function generateGameId(): string;
6
+ /**
7
+ * Format a date for display
8
+ */
9
+ export declare function formatDate(date: Date): string;
10
+ /**
11
+ * Get game display name
12
+ */
13
+ export declare function getGameDisplayName(gameType: GameType): string;
14
+ export * from './http-client.js';
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC;;GAEG;AACH,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAQ7C;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM,CAS7D;AAGD,cAAc,eAAe,CAAC"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Generate a unique game ID
3
+ */
4
+ export function generateGameId() {
5
+ return crypto.randomUUID();
6
+ }
7
+ /**
8
+ * Format a date for display
9
+ */
10
+ export function formatDate(date) {
11
+ return new Intl.DateTimeFormat('en-US', {
12
+ year: 'numeric',
13
+ month: 'short',
14
+ day: 'numeric',
15
+ hour: '2-digit',
16
+ minute: '2-digit',
17
+ }).format(date);
18
+ }
19
+ /**
20
+ * Get game display name
21
+ */
22
+ export function getGameDisplayName(gameType) {
23
+ switch (gameType) {
24
+ case 'tic-tac-toe':
25
+ return 'Tic-Tac-Toe';
26
+ case 'rock-paper-scissors':
27
+ return 'Rock Paper Scissors';
28
+ default:
29
+ return 'Unknown Game';
30
+ }
31
+ }
32
+ // Re-export HTTP client utilities
33
+ export * from './http-client.js';
34
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,UAAU,cAAc;IAC5B,OAAO,MAAM,CAAC,UAAU,EAAE,CAAC;AAC7B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,IAAU;IACnC,OAAO,IAAI,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE;QACtC,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,OAAO;QACd,GAAG,EAAE,SAAS;QACd,IAAI,EAAE,SAAS;QACf,MAAM,EAAE,SAAS;KAClB,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AAClB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,QAAkB;IACnD,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,aAAa;YAChB,OAAO,aAAa,CAAC;QACvB,KAAK,qBAAqB;YACxB,OAAO,qBAAqB,CAAC;QAC/B;YACE,OAAO,cAAc,CAAC;IAC1B,CAAC;AACH,CAAC;AAED,kCAAkC;AAClC,cAAc,eAAe,CAAC"}
@@ -0,0 +1,41 @@
1
+ // @ts-check
2
+
3
+ import eslint from '@eslint/js';
4
+ import tseslint from 'typescript-eslint';
5
+
6
+ export default tseslint.config(
7
+ eslint.configs.recommended,
8
+ ...tseslint.configs.recommended,
9
+ {
10
+ files: ['**/*.{js,mjs,cjs,ts}'],
11
+ languageOptions: {
12
+ parserOptions: {
13
+ ecmaVersion: 'latest',
14
+ sourceType: 'module',
15
+ },
16
+ },
17
+ rules: {
18
+ // Shared library specific rules
19
+ '@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
20
+ '@typescript-eslint/explicit-function-return-type': 'warn',
21
+ '@typescript-eslint/no-explicit-any': 'warn',
22
+ },
23
+ },
24
+ {
25
+ files: ['**/*.test.ts', '**/*.test.tsx', 'vitest.*.ts'],
26
+ rules: {
27
+ '@typescript-eslint/explicit-function-return-type': 'off',
28
+ '@typescript-eslint/no-explicit-any': 'off',
29
+ },
30
+ },
31
+ {
32
+ ignores: [
33
+ 'node_modules/**',
34
+ 'dist/**',
35
+ 'coverage/**',
36
+ '*.config.js',
37
+ '*.config.ts',
38
+ 'games.db',
39
+ ],
40
+ }
41
+ );
package/package.json ADDED
@@ -0,0 +1 @@
1
+ {"name": "turn-based-mcp-shared", "version": "1.0.0", "description": "Shared types and game logic for turn-based games", "type": "module", "main": "dist/index.js", "types": "dist/index.d.ts", "exports": {".": {"import": "./dist/index.js", "types": "./dist/index.d.ts"}, "./testing": {"import": "./dist/testing/index.js", "types": "./dist/testing/index.d.ts"}, "./constants": {"import": "./dist/constants/index.js", "types": "./dist/constants/index.d.ts"}}}