@apollo/client-ai-apps 0.3.1 → 0.3.2

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.
@@ -105,6 +105,11 @@ var ApplicationManifestPlugin = () => {
105
105
  if (!name2) {
106
106
  throw new Error("'name' argument must be supplied for @tool");
107
107
  }
108
+ if (name2.indexOf(" ") > -1) {
109
+ throw new Error(
110
+ `Tool with name "${name2}" contains spaces which is not allowed.`
111
+ );
112
+ }
108
113
  if (!description) {
109
114
  throw new Error(
110
115
  "'description' argument must be supplied for @tool"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apollo/client-ai-apps",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -562,6 +562,32 @@ describe("buildStart", () => {
562
562
  );
563
563
  });
564
564
 
565
+ test("Should error when tool name contains spaces", async () => {
566
+ vi.spyOn(fs, "readFileSync").mockImplementation((path) => {
567
+ if (path === "package.json") {
568
+ return JSON.stringify({});
569
+ } else if (path === "my-component.tsx") {
570
+ return `
571
+ const MY_QUERY = gql\`query HelloWorldQuery @tool(name: "hello world", description: "A tool") { helloWorld }\`;
572
+ `;
573
+ }
574
+ });
575
+ vi.spyOn(glob, "glob").mockImplementation(() =>
576
+ Promise.resolve(["my-component.tsx"])
577
+ );
578
+ vi.spyOn(path, "resolve").mockImplementation((_, file) => file);
579
+ vi.spyOn(fs, "writeFileSync");
580
+
581
+ const plugin = ApplicationManifestPlugin();
582
+ plugin.configResolved({ command: "serve", server: {} });
583
+
584
+ await expect(
585
+ async () => await plugin.buildStart()
586
+ ).rejects.toThrowErrorMatchingInlineSnapshot(
587
+ `[Error: Tool with name "hello world" contains spaces which is not allowed.]`
588
+ );
589
+ });
590
+
565
591
  test("Should error when tool name is not a string", async () => {
566
592
  vi.spyOn(fs, "readFileSync").mockImplementation((path) => {
567
593
  if (path === "package.json") {
@@ -140,6 +140,12 @@ export const ApplicationManifestPlugin = () => {
140
140
  throw new Error("'name' argument must be supplied for @tool");
141
141
  }
142
142
 
143
+ if (name.indexOf(" ") > -1) {
144
+ throw new Error(
145
+ `Tool with name "${name}" contains spaces which is not allowed.`
146
+ );
147
+ }
148
+
143
149
  if (!description) {
144
150
  throw new Error(
145
151
  "'description' argument must be supplied for @tool"