kitstore-cli 1.0.5 → 1.0.7

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.
@@ -172,7 +172,13 @@ describe('Install Command', () => {
172
172
  mockFsEnsureDir.mockResolvedValue(undefined);
173
173
  mockFsWriteFile.mockResolvedValue(undefined);
174
174
  await (0, install_1.installCommand)({ tag: 'test' });
175
- expect(mockRulesApi.rulesControllerFindAll).toHaveBeenCalledWith({ tag: 'test' });
175
+ expect(mockRulesApi.rulesControllerFindAll).toHaveBeenCalledWith(undefined, // page
176
+ undefined, // limit
177
+ 'test', // tag
178
+ undefined, // name
179
+ undefined, // type
180
+ undefined // authorId
181
+ );
176
182
  });
177
183
  // TC-UNIT-CLI-027: Install with type filtering
178
184
  it('should filter rules by type', async () => {
@@ -212,7 +218,13 @@ describe('Install Command', () => {
212
218
  mockFsEnsureDir.mockResolvedValue(undefined);
213
219
  mockFsWriteFile.mockResolvedValue(undefined);
214
220
  await (0, install_1.installCommand)({ type: 'rule' });
215
- expect(mockRulesApi.rulesControllerFindAll).toHaveBeenCalledWith({ type: 'rule' });
221
+ expect(mockRulesApi.rulesControllerFindAll).toHaveBeenCalledWith(undefined, // page
222
+ undefined, // limit
223
+ undefined, // tag
224
+ undefined, // name
225
+ 'rule', // type
226
+ undefined // authorId
227
+ );
216
228
  });
217
229
  // TC-UNIT-CLI-028: Install with file download failure
218
230
  it('should handle file download failure', async () => {
@@ -94,7 +94,13 @@ describe('List Command', () => {
94
94
  mockCreateApi.mockResolvedValue({ rulesApi: mockRulesApi });
95
95
  await (0, list_1.listCommand)({});
96
96
  expect(mockCreateApi).toHaveBeenCalledWith({ server: 'http://localhost:3000' });
97
- expect(mockRulesApi.rulesControllerFindAll).toHaveBeenCalledWith({});
97
+ expect(mockRulesApi.rulesControllerFindAll).toHaveBeenCalledWith(undefined, // page
98
+ undefined, // limit
99
+ undefined, // tag
100
+ undefined, // name
101
+ undefined, // type
102
+ undefined // authorId
103
+ );
98
104
  expect(console.log).toHaveBeenCalledWith(expect.stringContaining('📋 Found 2 rules/commands:'));
99
105
  });
100
106
  it('should apply filters when provided', async () => {
@@ -122,11 +128,13 @@ describe('List Command', () => {
122
128
  };
123
129
  mockCreateApi.mockResolvedValue({ rulesApi: mockRulesApi });
124
130
  await (0, list_1.listCommand)({ type: 'rule', tag: 'test', limit: '10' });
125
- expect(mockRulesApi.rulesControllerFindAll).toHaveBeenCalledWith({
126
- type: 'rule',
127
- tag: 'test',
128
- limit: 10,
129
- });
131
+ expect(mockRulesApi.rulesControllerFindAll).toHaveBeenCalledWith(undefined, // page
132
+ 10, // limit
133
+ 'test', // tag
134
+ undefined, // name
135
+ 'rule', // type
136
+ undefined // authorId
137
+ );
130
138
  });
131
139
  it('should handle empty results', async () => {
132
140
  mockGetConfig.mockResolvedValue({
@@ -123,7 +123,13 @@ describe('Login Command', () => {
123
123
  isAxiosError: true,
124
124
  response: {
125
125
  status: 401,
126
- data: { error: 'Invalid credentials' },
126
+ data: {
127
+ message: {
128
+ message: 'Invalid credentials',
129
+ error: 'Unauthorized',
130
+ statusCode: 401
131
+ }
132
+ },
127
133
  },
128
134
  message: 'Request failed with status code 401',
129
135
  };
@@ -145,6 +151,7 @@ describe('Login Command', () => {
145
151
  password: 'WrongPassword',
146
152
  })).rejects.toThrow();
147
153
  expect(mockSaveConfig).not.toHaveBeenCalled();
154
+ expect(console.error).toHaveBeenCalledWith('❌ Login failed: Invalid credentials');
148
155
  });
149
156
  // TC-UNIT-CLI-003: Interactive login prompts
150
157
  it('should prompt for email and password when not provided', async () => {
@@ -233,7 +240,13 @@ describe('Login Command', () => {
233
240
  isAxiosError: true,
234
241
  response: {
235
242
  status: 500,
236
- data: { error: 'Internal server error' },
243
+ data: {
244
+ message: {
245
+ message: 'Internal server error',
246
+ error: 'Internal Server Error',
247
+ statusCode: 500
248
+ }
249
+ },
237
250
  },
238
251
  message: 'Request failed with status code 500',
239
252
  };
@@ -84,9 +84,13 @@ describe('Search Command', () => {
84
84
  mockCreateApi.mockResolvedValue({ rulesApi: mockRulesApi });
85
85
  await (0, search_1.searchCommand)('auth', {});
86
86
  expect(mockCreateApi).toHaveBeenCalledWith({ server: 'http://localhost:3000' });
87
- expect(mockRulesApi.rulesControllerFindAll).toHaveBeenCalledWith({
88
- name: 'auth',
89
- });
87
+ expect(mockRulesApi.rulesControllerFindAll).toHaveBeenCalledWith(undefined, // page
88
+ undefined, // limit
89
+ undefined, // tag
90
+ 'auth', // name (search query)
91
+ undefined, // type
92
+ undefined // authorId
93
+ );
90
94
  expect(console.log).toHaveBeenCalledWith('🔍 Search results for "auth":');
91
95
  });
92
96
  it('should apply additional filters with search query', async () => {
@@ -114,11 +118,13 @@ describe('Search Command', () => {
114
118
  };
115
119
  mockCreateApi.mockResolvedValue({ rulesApi: mockRulesApi });
116
120
  await (0, search_1.searchCommand)('validation', { type: 'rule', limit: '5' });
117
- expect(mockRulesApi.rulesControllerFindAll).toHaveBeenCalledWith({
118
- name: 'validation',
119
- type: 'rule',
120
- limit: 5,
121
- });
121
+ expect(mockRulesApi.rulesControllerFindAll).toHaveBeenCalledWith(undefined, // page
122
+ 5, // limit
123
+ undefined, // tag
124
+ 'validation', // name (search query)
125
+ 'rule', // type
126
+ undefined // authorId
127
+ );
122
128
  });
123
129
  it('should handle no search results', async () => {
124
130
  mockGetConfig.mockResolvedValue({
@@ -54,12 +54,15 @@ async function installCommand(options) {
54
54
  process.exit(1);
55
55
  }
56
56
  const { rulesApi } = await (0, client_1.createApi)();
57
- // Query rules
58
- const response = await rulesApi.rulesControllerFindAll({
59
- tag: options.tag,
60
- name: options.name,
61
- type: options.type,
62
- });
57
+ // Query rules - pass parameters individually to match API client signature
58
+ // API expects: (page?: number, limit?: number, tag?: string, name?: string, type?: string, authorId?: string)
59
+ const response = await rulesApi.rulesControllerFindAll(undefined, // page (use default)
60
+ undefined, // limit (use default)
61
+ options.tag, // tag
62
+ options.name, // name
63
+ options.type, // type
64
+ undefined // authorId
65
+ );
63
66
  const rules = response.data;
64
67
  if (!rules || rules.length === 0) {
65
68
  console.log('📭 No rules found matching the criteria.');
@@ -140,7 +143,7 @@ async function installCommand(options) {
140
143
  }
141
144
  catch (err) {
142
145
  if (axios_1.default.isAxiosError(err)) {
143
- console.error('❌ Install failed:', err.response?.data?.error || err.message);
146
+ console.error('❌ Install failed:', err.response?.data?.message?.message || err.response?.data?.message || err.message);
144
147
  }
145
148
  else {
146
149
  console.error('❌ Install failed:', err);
@@ -19,16 +19,16 @@ async function listCommand(options) {
19
19
  process.exit(1);
20
20
  }
21
21
  const { rulesApi } = await (0, client_1.createApi)({ server: config.server });
22
- const queryParams = {};
23
- if (options.type)
24
- queryParams.type = options.type;
25
- if (options.tag)
26
- queryParams.tag = options.tag;
27
- if (options.name)
28
- queryParams.name = options.name;
29
- if (options.limit)
30
- queryParams.limit = parseInt(options.limit);
31
- const response = await rulesApi.rulesControllerFindAll(queryParams);
22
+ // Pass parameters individually to match API client signature
23
+ // API expects: (page?: number, limit?: number, tag?: string, name?: string, type?: string, authorId?: string)
24
+ const limit = options.limit ? parseInt(options.limit) : undefined;
25
+ const response = await rulesApi.rulesControllerFindAll(undefined, // page (use default)
26
+ limit, // limit
27
+ options.tag, // tag
28
+ options.name, // name
29
+ options.type, // type
30
+ undefined // authorId
31
+ );
32
32
  if (response.data && response.data.length > 0) {
33
33
  console.log(chalk_1.default.blue(`📋 Found ${response.data.length} rules/commands:`));
34
34
  console.log('');
@@ -60,7 +60,7 @@ async function listCommand(options) {
60
60
  catch (err) {
61
61
  if (err && typeof err === 'object' && 'response' in err) {
62
62
  const axiosError = err;
63
- console.error(chalk_1.default.red(`❌ Failed to list rules: ${axiosError.response?.data?.error || axiosError.message}`));
63
+ console.error(chalk_1.default.red(`❌ Failed to list rules: ${axiosError.response?.data?.message?.message || axiosError.response?.data?.message || axiosError.message}`));
64
64
  }
65
65
  else {
66
66
  console.error(chalk_1.default.red(`❌ Failed to list rules: ${err}`));
@@ -35,14 +35,16 @@ async function loginCommand(options) {
35
35
  }
36
36
  const response = await authApi.authControllerLogin({ email, password });
37
37
  const data = response.data;
38
- if (data.token) {
38
+ // Handle nested response structure from backend API
39
+ const loginData = data.success ? data.data : data;
40
+ if (loginData.token) {
39
41
  await (0, config_1.saveConfig)({
40
- token: data.token,
42
+ token: loginData.token,
41
43
  server,
42
- user: data.user,
44
+ user: loginData.user,
43
45
  lastLogin: new Date().toISOString(),
44
46
  });
45
- console.log(`✅ Logged in as ${data.user.username}`);
47
+ console.log(`✅ Logged in as ${loginData.user.username}`);
46
48
  }
47
49
  else {
48
50
  console.error('❌ Login failed');
@@ -51,7 +53,7 @@ async function loginCommand(options) {
51
53
  }
52
54
  catch (err) {
53
55
  if (axios_1.default.isAxiosError(err)) {
54
- console.error(`❌ Login failed: ${err.response?.data?.error || err.message}`);
56
+ console.error(`❌ Login failed: ${err.response?.data?.message?.message || err.response?.data?.message || err.message}`);
55
57
  }
56
58
  else if (err instanceof Error) {
57
59
  console.error(`❌ Login failed: ${err.message}`);
@@ -15,16 +15,16 @@ async function searchCommand(query, options) {
15
15
  process.exit(1);
16
16
  }
17
17
  const { rulesApi } = await (0, client_1.createApi)({ server: config.server });
18
- const queryParams = {
19
- name: query, // Search by name using the name filter
20
- };
21
- if (options.type)
22
- queryParams.type = options.type;
23
- if (options.tag)
24
- queryParams.tag = options.tag;
25
- if (options.limit)
26
- queryParams.limit = parseInt(options.limit);
27
- const response = await rulesApi.rulesControllerFindAll(queryParams);
18
+ // Pass parameters individually to match API client signature
19
+ // API expects: (page?: number, limit?: number, tag?: string, name?: string, type?: string, authorId?: string)
20
+ const limit = options.limit ? parseInt(options.limit) : undefined;
21
+ const response = await rulesApi.rulesControllerFindAll(undefined, // page (use default)
22
+ limit, // limit
23
+ options.tag, // tag
24
+ query, // name (search query)
25
+ options.type, // type
26
+ undefined // authorId
27
+ );
28
28
  if (response.data && response.data.length > 0) {
29
29
  console.log(`🔍 Search results for "${query}":`);
30
30
  console.log(`📋 Found ${response.data.length} matching rules/commands:`);
@@ -49,7 +49,7 @@ async function searchCommand(query, options) {
49
49
  catch (err) {
50
50
  if (err && typeof err === 'object' && 'response' in err) {
51
51
  const axiosError = err;
52
- console.error('❌ Search failed:', axiosError.response?.data?.error || axiosError.message);
52
+ console.error('❌ Search failed:', axiosError.response?.data?.message?.message || axiosError.response?.data?.message || axiosError.message);
53
53
  }
54
54
  else {
55
55
  console.error('❌ Search failed:', err);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kitstore-cli",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "CLI tool for Cursor Kit",
5
5
  "main": "dist/index.js",
6
6
  "bin": {