@salesforce/vite-plugin-lwc-ui-bundle 1.134.5 → 1.135.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.
- package/README.md +28 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -2
- package/dist/index.js.map +1 -1
- package/dist/providers/index.d.ts +1 -2
- package/dist/providers/index.d.ts.map +1 -1
- package/dist/providers/index.js +0 -3
- package/dist/providers/index.js.map +1 -1
- package/dist/providers/lds/index.d.ts +47 -2
- package/dist/providers/lds/index.d.ts.map +1 -1
- package/dist/providers/lds/index.js +54 -8
- package/dist/providers/lds/index.js.map +1 -1
- package/dist/providers/lds/runtime.js +158 -11
- package/dist/providers/lds/runtime.js.map +1 -1
- package/docs/consumer-guide.md +17 -10
- package/package.json +3 -7
- package/skills/setup-lwc-vite-plugin/SKILL.md +34 -24
- package/skills/setup-lwc-vite-plugin/references/known-pitfalls.md +27 -44
- package/dist/providers/lightning-graphql/index.d.ts +0 -10
- package/dist/providers/lightning-graphql/index.d.ts.map +0 -1
- package/dist/providers/lightning-graphql/index.js +0 -24
- package/dist/providers/lightning-graphql/index.js.map +0 -1
- package/dist/providers/lightning-graphql/runtime.js +0 -103
- package/dist/providers/lightning-graphql/runtime.js.map +0 -1
|
@@ -33,53 +33,31 @@ Prerelease tags get unpublished from the registry over time.
|
|
|
33
33
|
`npm view <pkg> version` and pin to `^<that>` instead of copying from
|
|
34
34
|
the snippet.
|
|
35
35
|
|
|
36
|
-
## 3. Hand-rolled
|
|
36
|
+
## 3. Hand-rolled GraphQL or LDS providers in `vite.config.js`
|
|
37
37
|
|
|
38
|
-
**Symptom:** `@wire(graphql)` returns empty data;
|
|
39
|
-
`No window.openai.callTool available` or a hand-written
|
|
40
|
-
`[
|
|
38
|
+
**Symptom:** `@wire(graphql)` or `@wire(getRecord)` returns empty data;
|
|
39
|
+
console shows `No window.openai.callTool available` or a hand-written
|
|
40
|
+
`[graphql] ...` / `[lds] ...` log message.
|
|
41
41
|
|
|
42
|
-
**Cause:** The generator treated the "include `builtins.
|
|
43
|
-
instruction as "write a provider called `
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
42
|
+
**Cause:** The generator treated the "include `builtins.lds()`"
|
|
43
|
+
instruction as "write a provider called `lds`" and inlined a custom
|
|
44
|
+
provider factory in `vite.config.js` instead of importing `builtins`
|
|
45
|
+
from the plugin. The hand-rolled version bypasses the plugin's real
|
|
46
|
+
runtime (which handles `getChatSDK()` MCP dispatch, `normalizeMcpResponse`
|
|
47
|
+
envelope parsing, and the graphql-specific `{ data, errors[] }`
|
|
48
|
+
envelope).
|
|
48
49
|
|
|
49
50
|
**Fix:** Replace with:
|
|
50
51
|
|
|
51
52
|
```js
|
|
52
53
|
import lwcVitePlugin, { builtins } from "@salesforce/vite-plugin-lwc-ui-bundle";
|
|
53
54
|
// inside lwcVitePlugin({ providers: [...] })
|
|
54
|
-
builtins.
|
|
55
|
-
builtins.lds(),
|
|
55
|
+
builtins.lds(), // covers lightning/uiRecordApi, uiObjectInfoApi, and lightning/graphql
|
|
56
56
|
```
|
|
57
57
|
|
|
58
|
-
Same rule for
|
|
58
|
+
Same rule for every other provider — never hand-write them.
|
|
59
59
|
|
|
60
|
-
## 4.
|
|
61
|
-
|
|
62
|
-
**Symptom:** `@wire(graphql)` with a class-based SDK (e.g.
|
|
63
|
-
`@salesforce/sdk-data`'s `WebApp`) silently emits
|
|
64
|
-
`{data: undefined, errors: [TypeError]}`; component falls through to an
|
|
65
|
-
empty state.
|
|
66
|
-
|
|
67
|
-
**Cause:** Plugin versions ≤ 1.132.0 destructure `graphql` off
|
|
68
|
-
`globalThis.__sfdc_sdk__` before calling it, which loses the method's
|
|
69
|
-
`this` binding. The method internally calls `this.fetch(...)` and
|
|
70
|
-
blows up.
|
|
71
|
-
|
|
72
|
-
**Fix:** Fixed in webapps PR #477 (plugin version > 1.132.0). Until the
|
|
73
|
-
fix ships in a release, add this to `bootstrap.js` after creating the
|
|
74
|
-
SDK:
|
|
75
|
-
|
|
76
|
-
```js
|
|
77
|
-
sdk.graphql = sdk.graphql.bind(sdk);
|
|
78
|
-
sdk.fetch = sdk.fetch.bind(sdk);
|
|
79
|
-
globalThis.__sfdc_sdk__ = sdk;
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
## 5. Wrong tool name in mock branch (graphql foot-gun)
|
|
60
|
+
## 4. Wrong tool name in mock branch (graphql foot-gun)
|
|
83
61
|
|
|
84
62
|
**Symptom:** `@wire(graphql)` returns empty data even though the mock
|
|
85
63
|
shim is installed; console shows "[mock] unhandled tool: graphqlQuery"
|
|
@@ -93,8 +71,13 @@ variables })` by default, but the mock branches on `"graphql"` or
|
|
|
93
71
|
the same custom name to both the provider and the mock:
|
|
94
72
|
|
|
95
73
|
```js
|
|
96
|
-
// vite.config.js
|
|
97
|
-
builtins.
|
|
74
|
+
// vite.config.js — override the default "graphqlQuery" tool name
|
|
75
|
+
builtins.lds({
|
|
76
|
+
"lightning/graphql": {
|
|
77
|
+
graphql: { type: "graphql-wire", toolName: "myCustomGraphql" },
|
|
78
|
+
executeMutation: { type: "graphql-mutation", toolName: "myCustomGraphql" },
|
|
79
|
+
},
|
|
80
|
+
}),
|
|
98
81
|
|
|
99
82
|
// bootstrap.js
|
|
100
83
|
if (name === "myCustomGraphql") { /* ... */ }
|
|
@@ -103,7 +86,7 @@ if (name === "myCustomGraphql") { /* ... */ }
|
|
|
103
86
|
The vite-config tool name and the mock-branch string must match
|
|
104
87
|
exactly.
|
|
105
88
|
|
|
106
|
-
##
|
|
89
|
+
## 5. `.properties` wrap in Avro/JSON-schema-serialized tool output
|
|
107
90
|
|
|
108
91
|
**Symptom:** Chat wrapper renders "Waiting for tool output..." even
|
|
109
92
|
though the host fired tool output; mapper's `Object.keys(records)[0]`
|
|
@@ -128,7 +111,7 @@ function unwrapPropertiesMap(value) {
|
|
|
128
111
|
|
|
129
112
|
Apply this in every mapper that reads map-shaped fields.
|
|
130
113
|
|
|
131
|
-
##
|
|
114
|
+
## 6. Missing `viteSingleFile()`
|
|
132
115
|
|
|
133
116
|
**Symptom:** `dist/index.html` is 1-2 KB (just a stub); component
|
|
134
117
|
doesn't render when opened locally.
|
|
@@ -155,7 +138,7 @@ build: {
|
|
|
155
138
|
|
|
156
139
|
A correctly built `dist/index.html` is typically 100 KB+.
|
|
157
140
|
|
|
158
|
-
##
|
|
141
|
+
## 7. `@salesforce/label/...` warnings
|
|
159
142
|
|
|
160
143
|
**Symptom:** Build warns `Unhandled import: @salesforce/label/...`,
|
|
161
144
|
but the build succeeds.
|
|
@@ -166,7 +149,7 @@ when no override is provided.
|
|
|
166
149
|
**Fix:** Not a bug. Add overrides to `builtins.label({...})` to
|
|
167
150
|
customize the displayed text.
|
|
168
151
|
|
|
169
|
-
##
|
|
152
|
+
## 8. Missing gate / accessCheck providers with lightning-base-components
|
|
170
153
|
|
|
171
154
|
**Symptom:** Build fails with `Cannot read properties of undefined
|
|
172
155
|
(reading 'isOpen')`.
|
|
@@ -179,7 +162,7 @@ import them.
|
|
|
179
162
|
(and `builtins.primitiveUtils()`) whenever `lightning-base-components`
|
|
180
163
|
is in the modules config.
|
|
181
164
|
|
|
182
|
-
##
|
|
165
|
+
## 9. Core-only imports
|
|
183
166
|
|
|
184
167
|
**Symptom:** `Rollup failed to resolve import "force/someModule"` (or
|
|
185
168
|
`aura`, `logger`, etc.).
|
|
@@ -198,7 +181,7 @@ lwcVitePlugin({
|
|
|
198
181
|
Point the stub at a minimal file that exports the shape the importer
|
|
199
182
|
expects.
|
|
200
183
|
|
|
201
|
-
##
|
|
184
|
+
## 10. Mock data doesn't work in production build
|
|
202
185
|
|
|
203
186
|
**Symptom:** `npm run build && open dist/index.html` shows wrappers in
|
|
204
187
|
"Waiting" state; `sdk.callTool is not available on this surface` in
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Provider } from '../../types';
|
|
2
|
-
export interface LightningGraphqlOptions {
|
|
3
|
-
/**
|
|
4
|
-
* Name of the MCP tool to call for GraphQL query execution.
|
|
5
|
-
* Defaults to `'graphqlQuery'`.
|
|
6
|
-
*/
|
|
7
|
-
toolName?: string;
|
|
8
|
-
}
|
|
9
|
-
export declare function lightningGraphql(options?: LightningGraphqlOptions): Provider;
|
|
10
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/lightning-graphql/index.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,WAAW,uBAAuB;IACvC;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB;AAOD,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,uBAA4B,GAAG,QAAQ,CAUhF"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { readFileSync } from "node:fs";
|
|
2
|
-
import { join, dirname } from "node:path";
|
|
3
|
-
import { fileURLToPath } from "node:url";
|
|
4
|
-
const runtimeSource = readFileSync(
|
|
5
|
-
join(dirname(fileURLToPath(import.meta.url)), "runtime.js"),
|
|
6
|
-
"utf-8"
|
|
7
|
-
);
|
|
8
|
-
function lightningGraphql(options = {}) {
|
|
9
|
-
const toolName = options.toolName ?? "graphqlQuery";
|
|
10
|
-
const source = `${runtimeSource}
|
|
11
|
-
TOOL_NAME = ${JSON.stringify(toolName)};
|
|
12
|
-
`;
|
|
13
|
-
return {
|
|
14
|
-
match: (id) => id === "lightning/graphql",
|
|
15
|
-
resolve(specifier) {
|
|
16
|
-
if (specifier !== "lightning/graphql") return null;
|
|
17
|
-
return source;
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
export {
|
|
22
|
-
lightningGraphql
|
|
23
|
-
};
|
|
24
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/providers/lightning-graphql/index.ts"],"sourcesContent":["/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport { readFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport type { Provider } from \"../../types\";\n\nexport interface LightningGraphqlOptions {\n\t/**\n\t * Name of the MCP tool to call for GraphQL query execution.\n\t * Defaults to `'graphqlQuery'`.\n\t */\n\ttoolName?: string;\n}\n\nconst runtimeSource = readFileSync(\n\tjoin(dirname(fileURLToPath(import.meta.url)), \"runtime.js\"),\n\t\"utf-8\",\n);\n\nexport function lightningGraphql(options: LightningGraphqlOptions = {}): Provider {\n\tconst toolName = options.toolName ?? \"graphqlQuery\";\n\tconst source = `${runtimeSource}\\nTOOL_NAME = ${JSON.stringify(toolName)};\\n`;\n\treturn {\n\t\tmatch: (id) => id === \"lightning/graphql\",\n\t\tresolve(specifier) {\n\t\t\tif (specifier !== \"lightning/graphql\") return null;\n\t\t\treturn source;\n\t\t},\n\t};\n}\n"],"names":[],"mappings":";;;AAkBA,MAAM,gBAAgB;AAAA,EACrB,KAAK,QAAQ,cAAc,YAAY,GAAG,CAAC,GAAG,YAAY;AAAA,EAC1D;AACD;AAEO,SAAS,iBAAiB,UAAmC,IAAc;AACjF,QAAM,WAAW,QAAQ,YAAY;AACrC,QAAM,SAAS,GAAG,aAAa;AAAA,cAAiB,KAAK,UAAU,QAAQ,CAAC;AAAA;AACxE,SAAO;AAAA,IACN,OAAO,CAAC,OAAO,OAAO;AAAA,IACtB,QAAQ,WAAW;AAClB,UAAI,cAAc,oBAAqB,QAAO;AAC9C,aAAO;AAAA,IACR;AAAA,EAAA;AAEF;"}
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { getChatSDK } from "@salesforce/sdk-chat";
|
|
2
|
-
function normalizeMcpResponse(raw) {
|
|
3
|
-
if (raw && typeof raw === "object" && "structuredContent" in raw) {
|
|
4
|
-
return raw.structuredContent;
|
|
5
|
-
}
|
|
6
|
-
if (raw && typeof raw === "object" && typeof raw.result === "string") {
|
|
7
|
-
const parsed = JSON.parse(raw.result);
|
|
8
|
-
if (Array.isArray(parsed)) {
|
|
9
|
-
const textBlock = parsed.find(
|
|
10
|
-
(b) => b && b.type === "text" && typeof b.text === "string"
|
|
11
|
-
);
|
|
12
|
-
const text = textBlock ? textBlock.text : null;
|
|
13
|
-
if (text) {
|
|
14
|
-
return JSON.parse(text);
|
|
15
|
-
}
|
|
16
|
-
return {};
|
|
17
|
-
}
|
|
18
|
-
return parsed;
|
|
19
|
-
}
|
|
20
|
-
return raw ?? {};
|
|
21
|
-
}
|
|
22
|
-
let TOOL_NAME = "graphqlQuery";
|
|
23
|
-
function gql(strings, ...values) {
|
|
24
|
-
let result = "";
|
|
25
|
-
strings.forEach((string, i) => {
|
|
26
|
-
result += string;
|
|
27
|
-
if (i < values.length) result += String(values[i]);
|
|
28
|
-
});
|
|
29
|
-
return result;
|
|
30
|
-
}
|
|
31
|
-
async function runQuery(config) {
|
|
32
|
-
const { query, variables } = config;
|
|
33
|
-
if (!query) return { data: void 0, errors: void 0 };
|
|
34
|
-
const sdkRef = globalThis.__sfdc_sdk__;
|
|
35
|
-
if (sdkRef && typeof sdkRef.graphql === "function") {
|
|
36
|
-
const result = await sdkRef.graphql({ query, variables: variables ?? {} });
|
|
37
|
-
return { data: result?.data, errors: result?.errors };
|
|
38
|
-
}
|
|
39
|
-
const sdk = await getChatSDK();
|
|
40
|
-
if (typeof sdk.callTool !== "function") {
|
|
41
|
-
throw new Error(
|
|
42
|
-
"[lightning/graphql] No data surface available. Either initialise globalThis.__sfdc_sdk__ with createDataSDK, or run inside a ChatGPT / MCP Apps context."
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
const raw = await sdk.callTool({
|
|
46
|
-
toolName: TOOL_NAME,
|
|
47
|
-
params: { query, variables: variables ?? {} }
|
|
48
|
-
});
|
|
49
|
-
return normalizeMcpResponse(raw) ?? {};
|
|
50
|
-
}
|
|
51
|
-
class graphql {
|
|
52
|
-
_dataCallback;
|
|
53
|
-
_config;
|
|
54
|
-
constructor(dataCallback) {
|
|
55
|
-
this._dataCallback = dataCallback;
|
|
56
|
-
}
|
|
57
|
-
connect() {
|
|
58
|
-
this._fetch();
|
|
59
|
-
}
|
|
60
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
61
|
-
disconnect() {
|
|
62
|
-
}
|
|
63
|
-
update(config) {
|
|
64
|
-
this._config = config;
|
|
65
|
-
this._fetch();
|
|
66
|
-
}
|
|
67
|
-
refresh() {
|
|
68
|
-
return this._fetch();
|
|
69
|
-
}
|
|
70
|
-
async _fetch() {
|
|
71
|
-
try {
|
|
72
|
-
const result = await runQuery(this._config ?? {});
|
|
73
|
-
this._emit(result);
|
|
74
|
-
} catch (error) {
|
|
75
|
-
this._emit({
|
|
76
|
-
data: void 0,
|
|
77
|
-
errors: [{ message: error.message }]
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
_emit({ data, errors }) {
|
|
82
|
-
this._dataCallback({
|
|
83
|
-
data,
|
|
84
|
-
errors: errors?.length ? errors : void 0,
|
|
85
|
-
refresh: () => this.refresh()
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
async function executeMutation(config) {
|
|
90
|
-
if (!config?.query) return { data: void 0, errors: [{ message: "No query provided" }] };
|
|
91
|
-
try {
|
|
92
|
-
return await runQuery(config);
|
|
93
|
-
} catch (error) {
|
|
94
|
-
return { data: void 0, errors: [{ message: error.message }] };
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
export {
|
|
98
|
-
TOOL_NAME,
|
|
99
|
-
executeMutation,
|
|
100
|
-
gql,
|
|
101
|
-
graphql
|
|
102
|
-
};
|
|
103
|
-
//# sourceMappingURL=runtime.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.js","sources":["../../../src/providers/shared/normalize-mcp-response.ts","../../../src/providers/lightning-graphql/runtime.ts"],"sourcesContent":["/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\n\n/**\n * Unwraps the MCP tool transport envelope and returns the tool's payload as-is.\n *\n * Handles the three surface shapes `sdk.callTool()` can resolve with:\n * - MCP Apps surface: `{ structuredContent, content }`\n * - OpenAI surface: `{ result: \"<JSON string>\" }`, where the JSON may itself be\n * an MCP content array (`[{ type: 'text', text: \"<JSON string>\" }, ...]`)\n * - Fallback: the raw value returned by `callTool`\n *\n * The shape of the unwrapped payload is the tool's responsibility — this helper\n * does not project out `data` / `error` / `errors`. Callers read whichever keys\n * their tool contract defines.\n */\nexport function normalizeMcpResponse(raw: unknown): unknown {\n\tif (raw && typeof raw === \"object\" && \"structuredContent\" in raw) {\n\t\treturn (raw as { structuredContent: unknown }).structuredContent;\n\t}\n\n\tif (raw && typeof raw === \"object\" && typeof (raw as { result?: unknown }).result === \"string\") {\n\t\tconst parsed = JSON.parse((raw as { result: string }).result);\n\t\tif (Array.isArray(parsed)) {\n\t\t\tconst textBlock = parsed.find(\n\t\t\t\t(b: { type?: string; text?: string }) =>\n\t\t\t\t\tb && b.type === \"text\" && typeof b.text === \"string\",\n\t\t\t);\n\t\t\tconst text = textBlock ? textBlock.text : null;\n\t\t\tif (text) {\n\t\t\t\treturn JSON.parse(text);\n\t\t\t}\n\t\t\treturn {};\n\t\t}\n\t\treturn parsed;\n\t}\n\n\treturn raw ?? {};\n}\n","/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport { getChatSDK } from \"@salesforce/sdk-chat\";\nimport { normalizeMcpResponse } from \"../shared/normalize-mcp-response\";\n\n// Overwritten at plugin-load time by the `lightningGraphql` Vite shim, which\n// appends `TOOL_NAME = \"<configured-name>\";` to the bundled output. The initial\n// value is the default.\n// eslint-disable-next-line prefer-const\nexport let TOOL_NAME = \"graphqlQuery\";\n\ninterface GraphqlConfig {\n\tquery?: string;\n\tvariables?: Record<string, unknown>;\n}\n\ninterface GraphqlResult {\n\tdata?: unknown;\n\terrors?: { message: string }[];\n}\n\ntype WireCallback = (result: {\n\tdata: unknown;\n\terrors: { message: string }[] | undefined;\n\trefresh: () => Promise<void>;\n}) => void;\n\nexport function gql(strings: TemplateStringsArray, ...values: unknown[]): string {\n\tlet result = \"\";\n\tstrings.forEach((string, i) => {\n\t\tresult += string;\n\t\tif (i < values.length) result += String(values[i]);\n\t});\n\treturn result;\n}\n\nasync function runQuery(config: GraphqlConfig): Promise<GraphqlResult> {\n\tconst { query, variables } = config;\n\tif (!query) return { data: undefined, errors: undefined };\n\n\t// 1. UIBundle / local dev: use globalThis.__sfdc_sdk__.graphql if available.\n\t// Invoke as a method (not a destructured reference) so class-based SDK\n\t// implementations keep their `this` binding — some SDKs implement\n\t// `graphql` as a method that calls `this.fetch(...)` internally.\n\tconst sdkRef = (globalThis as Record<string, unknown>).__sfdc_sdk__ as\n\t\t| {\n\t\t\t\tgraphql?: (args: {\n\t\t\t\t\tquery: string;\n\t\t\t\t\tvariables: Record<string, unknown>;\n\t\t\t\t}) => Promise<GraphqlResult>;\n\t\t }\n\t\t| undefined;\n\tif (sdkRef && typeof sdkRef.graphql === \"function\") {\n\t\tconst result = await sdkRef.graphql({ query, variables: variables ?? {} });\n\t\treturn { data: result?.data, errors: result?.errors };\n\t}\n\n\t// 2. MCP surface: use getChatSDK().callTool\n\tconst sdk = await getChatSDK();\n\tif (typeof sdk.callTool !== \"function\") {\n\t\tthrow new Error(\n\t\t\t\"[lightning/graphql] No data surface available. \" +\n\t\t\t\t\"Either initialise globalThis.__sfdc_sdk__ with createDataSDK, \" +\n\t\t\t\t\"or run inside a ChatGPT / MCP Apps context.\",\n\t\t);\n\t}\n\n\tconst raw = await sdk.callTool({\n\t\ttoolName: TOOL_NAME,\n\t\tparams: { query, variables: variables ?? {} },\n\t});\n\n\treturn (normalizeMcpResponse(raw) as GraphqlResult) ?? {};\n}\n\nexport class graphql {\n\t_dataCallback: WireCallback;\n\t_config: GraphqlConfig | undefined;\n\n\tconstructor(dataCallback: WireCallback) {\n\t\tthis._dataCallback = dataCallback;\n\t}\n\n\tconnect() {\n\t\tthis._fetch();\n\t}\n\n\t// eslint-disable-next-line @typescript-eslint/no-empty-function\n\tdisconnect() {}\n\n\tupdate(config: GraphqlConfig) {\n\t\tthis._config = config;\n\t\tthis._fetch();\n\t}\n\n\trefresh() {\n\t\treturn this._fetch();\n\t}\n\n\tasync _fetch() {\n\t\ttry {\n\t\t\tconst result = await runQuery(this._config ?? {});\n\t\t\tthis._emit(result);\n\t\t} catch (error) {\n\t\t\tthis._emit({\n\t\t\t\tdata: undefined,\n\t\t\t\terrors: [{ message: (error as Error).message }],\n\t\t\t});\n\t\t}\n\t}\n\n\t_emit({ data, errors }: GraphqlResult) {\n\t\tthis._dataCallback({\n\t\t\tdata,\n\t\t\terrors: errors?.length ? errors : undefined,\n\t\t\trefresh: () => this.refresh(),\n\t\t});\n\t}\n}\n\nexport async function executeMutation(config: GraphqlConfig): Promise<GraphqlResult> {\n\tif (!config?.query) return { data: undefined, errors: [{ message: \"No query provided\" }] };\n\ttry {\n\t\treturn await runQuery(config);\n\t} catch (error) {\n\t\treturn { data: undefined, errors: [{ message: (error as Error).message }] };\n\t}\n}\n"],"names":[],"mappings":";AAmBO,SAAS,qBAAqB,KAAuB;AAC3D,MAAI,OAAO,OAAO,QAAQ,YAAY,uBAAuB,KAAK;AACjE,WAAQ,IAAuC;AAAA,EAChD;AAEA,MAAI,OAAO,OAAO,QAAQ,YAAY,OAAQ,IAA6B,WAAW,UAAU;AAC/F,UAAM,SAAS,KAAK,MAAO,IAA2B,MAAM;AAC5D,QAAI,MAAM,QAAQ,MAAM,GAAG;AAC1B,YAAM,YAAY,OAAO;AAAA,QACxB,CAAC,MACA,KAAK,EAAE,SAAS,UAAU,OAAO,EAAE,SAAS;AA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