Skip to content

Commit aaca331

Browse files
Merge pull request #39 from useshortcut/amcd/search-by-name-bug
Fix searching by name.
2 parents b139b8a + 02bf6e1 commit aaca331

File tree

4 files changed

+16
-8
lines changed

4 files changed

+16
-8
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"modelcontextprotocol"
1313
],
1414
"license": "MIT",
15-
"version": "0.5.0",
15+
"version": "0.5.1",
1616
"type": "module",
1717
"main": "dist/index.js",
1818
"bin": {

src/tools/epics.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ describe("EpicTools", () => {
279279
});
280280

281281
expect(searchEpicsMock.mock.calls?.[0]?.[0]).toBe(
282-
'id:1 name:"Test Epic" description:"Test Description" state:started objective:123 owner:testuser team:engineering is:archived',
282+
'id:1 title:"Test Epic" description:"Test Description" state:started objective:123 owner:testuser group:engineering is:archived',
283283
);
284284
});
285285

src/tools/utils/search.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ describe("buildSearchQuery", () => {
4848
state: "started",
4949
};
5050
const result = await buildSearchQuery(params, null);
51-
expect(result).toBe("name:test state:started");
51+
expect(result).toBe("title:test state:started");
5252
});
5353

5454
test("should quote string parameters with spaces", async () => {
@@ -57,7 +57,7 @@ describe("buildSearchQuery", () => {
5757
description: "some description",
5858
};
5959
const result = await buildSearchQuery(params, null);
60-
expect(result).toBe('name:"test story" description:"some description"');
60+
expect(result).toBe('title:"test story" description:"some description"');
6161
});
6262

6363
test("should handle mixed parameter types correctly", async () => {
@@ -68,7 +68,7 @@ describe("buildSearchQuery", () => {
6868
hasOwner: false,
6969
};
7070
const result = await buildSearchQuery(params, null);
71-
expect(result).toBe("id:123 name:test is:started !has:owner");
71+
expect(result).toBe("id:123 title:test is:started !has:owner");
7272
});
7373

7474
test('should replace "me" with current user mention name for owner parameter', async () => {

src/tools/utils/search.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
import type { MemberInfo } from "@shortcut/client";
22

3+
const keyRenames = { team: "group", name: "title" } as const;
4+
5+
const mapKeyName = (key: string) => {
6+
const lowercaseKey = key.toLowerCase();
7+
8+
return keyRenames[lowercaseKey as keyof typeof keyRenames] || lowercaseKey;
9+
};
10+
311
const getKey = (prop: string) => {
4-
if (prop.startsWith("is")) return `is:${prop.slice(2).toLowerCase()}`;
5-
if (prop.startsWith("has")) return `has:${prop.slice(3).toLowerCase()}`;
6-
return prop;
12+
if (prop.startsWith("is")) return `is:${mapKeyName(prop.slice(2))}`;
13+
if (prop.startsWith("has")) return `has:${mapKeyName(prop.slice(3))}`;
14+
return mapKeyName(prop);
715
};
816

917
export type QueryParams = { [key: string]: boolean | string | number };

0 commit comments

Comments
 (0)