@apollo/client-ai-apps 0.1.1 → 0.2.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.
@@ -31,22 +31,22 @@ jobs:
31
31
  shell: bash
32
32
  run: npm run build
33
33
 
34
- # - name: Test
35
- # shell: bash
36
- # run: npm run test
37
-
38
- # - name: Configure Git
39
- # run: |
40
- # git config --global user.name GitHub Actions
41
- # git config user.email github-actions@github.com
42
-
43
- # - uses: knope-dev/action@v2.1.0
44
- # with:
45
- # version: 0.21.5
46
-
47
- # - run: knope release
48
- # env:
49
- # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34
+ - name: Test
35
+ shell: bash
36
+ run: npm run test
37
+
38
+ - name: Configure Git
39
+ run: |
40
+ git config --global user.name GitHub Actions
41
+ git config user.email github-actions@github.com
42
+
43
+ - uses: knope-dev/action@v2.1.0
44
+ with:
45
+ version: 0.21.5
46
+
47
+ - run: knope release
48
+ env:
49
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50
50
 
51
51
  - name: Publish to npm
52
52
  shell: bash
@@ -1,4 +1,6 @@
1
1
  import { DisplayMode } from "../types/openai";
2
2
  export declare const useRequestDisplayMode: () => (args: {
3
3
  mode: DisplayMode;
4
- }) => Promise<void>;
4
+ }) => Promise<{
5
+ mode: DisplayMode;
6
+ }>;
package/dist/index.js CHANGED
@@ -51,7 +51,7 @@ var useSendFollowUpMessage = () => {
51
51
  // src/hooks/useRequestDisplayMode.ts
52
52
  var useRequestDisplayMode = () => {
53
53
  return async (args) => {
54
- await window.openai?.requestDisplayMode(args);
54
+ return await window.openai?.requestDisplayMode(args);
55
55
  };
56
56
  };
57
57
 
@@ -1,6 +1,6 @@
1
1
  import { TypeNode, type DocumentNode } from "graphql";
2
2
  export declare function getTypeName(type: TypeNode): string;
3
- export declare const OperationManifestPlugin: () => {
3
+ export declare const ApplicationManifestPlugin: () => {
4
4
  name: string;
5
5
  configResolved(resolvedConfig: any): Promise<void>;
6
6
  buildStart(): Promise<void>;
@@ -1 +1 @@
1
- export * from "./operation_manifest_plugin";
1
+ export * from "./application_manifest_plugin";
@@ -1,4 +1,4 @@
1
- // src/vite/operation_manifest_plugin.ts
1
+ // src/vite/application_manifest_plugin.ts
2
2
  import { readFileSync, writeFileSync } from "fs";
3
3
  import { glob } from "glob";
4
4
  import { gqlPluckFromCodeStringSync } from "@graphql-tools/graphql-tag-pluck";
@@ -35,7 +35,7 @@ function getTypeName(type) {
35
35
  }
36
36
  return t.name.value;
37
37
  }
38
- var OperationManifestPlugin = () => {
38
+ var ApplicationManifestPlugin = () => {
39
39
  const cache = /* @__PURE__ */ new Map();
40
40
  let packageJson = null;
41
41
  let config = null;
@@ -127,7 +127,11 @@ var OperationManifestPlugin = () => {
127
127
  description: packageJson.description,
128
128
  hash: createHash("sha256").update(Date.now().toString()).digest("hex"),
129
129
  operations: Array.from(cache.values()).flatMap((entry) => entry.operations),
130
- resource
130
+ resource,
131
+ csp: {
132
+ connectDomains: packageJson.csp?.connectDomains ?? [],
133
+ resourceDomains: packageJson.csp?.resourceDomains ?? []
134
+ }
131
135
  };
132
136
  if (config.command === "build") {
133
137
  const dest = path.resolve(root, config.build.outDir, ".application-manifest.json");
@@ -204,7 +208,7 @@ function removeClientDirective(doc) {
204
208
  });
205
209
  }
206
210
  export {
207
- OperationManifestPlugin,
211
+ ApplicationManifestPlugin,
208
212
  getTypeName,
209
213
  sortTopLevelDefinitions
210
214
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apollo/client-ai-apps",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -52,4 +52,4 @@
52
52
  "crypto-hash": "^4.0.0",
53
53
  "glob": "^11.0.3"
54
54
  }
55
- }
55
+ }
@@ -0,0 +1,17 @@
1
+ import { expect, test, vi } from "vitest";
2
+ import { useRequestDisplayMode } from "./useRequestDisplayMode";
3
+ import { DisplayMode } from "../types/openai";
4
+
5
+ test("Should set display mode when returned function is called", async () => {
6
+ vi.stubGlobal("openai", {
7
+ requestDisplayMode: vi.fn(async (args: { mode: DisplayMode }) => {
8
+ return args;
9
+ }),
10
+ });
11
+
12
+ const requestDisplayMode = useRequestDisplayMode();
13
+ const result = await requestDisplayMode({ mode: "inline" });
14
+
15
+ expect(window.openai.requestDisplayMode).toBeCalledWith({ mode: "inline" });
16
+ expect(result).toEqual({ mode: "inline" });
17
+ });
@@ -2,6 +2,6 @@ import { DisplayMode } from "../types/openai";
2
2
 
3
3
  export const useRequestDisplayMode = () => {
4
4
  return async (args: { mode: DisplayMode }) => {
5
- await window.openai?.requestDisplayMode(args);
5
+ return await window.openai?.requestDisplayMode(args);
6
6
  };
7
7
  };
@@ -46,7 +46,7 @@ export function getTypeName(type: TypeNode): string {
46
46
  return (t as NamedTypeNode).name.value;
47
47
  }
48
48
 
49
- export const OperationManifestPlugin = () => {
49
+ export const ApplicationManifestPlugin = () => {
50
50
  const cache = new Map();
51
51
  let packageJson: any = null;
52
52
  let config: any = null;
@@ -166,6 +166,10 @@ export const OperationManifestPlugin = () => {
166
166
  hash: createHash("sha256").update(Date.now().toString()).digest("hex"),
167
167
  operations: Array.from(cache.values()).flatMap((entry) => entry.operations),
168
168
  resource,
169
+ csp: {
170
+ connectDomains: packageJson.csp?.connectDomains ?? [],
171
+ resourceDomains: packageJson.csp?.resourceDomains ?? [],
172
+ },
169
173
  };
170
174
 
171
175
  if (config.command === "build") {
package/src/vite/index.ts CHANGED
@@ -1 +1 @@
1
- export * from "./operation_manifest_plugin";
1
+ export * from "./application_manifest_plugin";