@salesforce/vite-plugin-lwc-ui-bundle 9.16.1 → 9.17.1

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.
@@ -1,57 +1,109 @@
1
+ import { init, parse } from "es-module-lexer";
2
+ import MagicString from "magic-string";
1
3
  import { readFileSync } from "node:fs";
2
4
  import { join, dirname } from "node:path";
3
5
  import { fileURLToPath } from "node:url";
4
- import { init, parse } from "es-module-lexer";
5
- import MagicString from "magic-string";
6
- const ADAPTER_PREFIX = "sf-lds-adapter:";
7
- const ADAPTER_ID_PREFIX = "\0" + ADAPTER_PREFIX;
8
- const adapterBaseSource = stripTopLevelExports(
9
- readFileSync(join(dirname(fileURLToPath(import.meta.url)), "runtime.js"), "utf-8")
10
- );
6
+ function isGraphqlSpecifier(moduleAdapters) {
7
+ return Object.values(moduleAdapters).some(
8
+ (entry) => entry.type === "graphql-wire" || entry.type === "graphql-mutation" || entry.type === "graphql-imperative-read"
9
+ );
10
+ }
11
+ const RECORD_TOOL = "getRecordMcpTool";
12
+ const RECORD_SCHEMA = {
13
+ type: "object",
14
+ properties: {
15
+ recordId: { type: "string" },
16
+ layoutTypes: {
17
+ anyOf: [{ type: "array", items: { type: "string" } }, { type: "null" }]
18
+ },
19
+ fields: {
20
+ anyOf: [{ type: "array", items: { type: "string" } }, { type: "null" }]
21
+ }
22
+ },
23
+ required: ["recordId"],
24
+ additionalProperties: false,
25
+ anyOf: [
26
+ {
27
+ type: "object",
28
+ properties: {
29
+ fields: { type: "array", items: { type: "string" }, minItems: 1 }
30
+ },
31
+ required: ["fields"],
32
+ additionalProperties: true
33
+ },
34
+ {
35
+ type: "object",
36
+ properties: {
37
+ layoutTypes: {
38
+ type: "array",
39
+ items: { type: "string" },
40
+ minItems: 1
41
+ }
42
+ },
43
+ required: ["layoutTypes"],
44
+ additionalProperties: true
45
+ }
46
+ ]
47
+ };
48
+ const OBJECT_INFO_TOOL = "getObjectInfoMcpTool";
49
+ const OBJECT_INFO_SCHEMA = {
50
+ type: "object",
51
+ properties: {
52
+ objectApiName: { type: "string" }
53
+ },
54
+ required: ["objectApiName"],
55
+ additionalProperties: false
56
+ };
57
+ const GRAPHQL_TOOL = "graphqlQuery";
58
+ function isStateManagerSpecifier(moduleAdapters) {
59
+ return Object.values(moduleAdapters).some((entry) => entry.type === "state-manager");
60
+ }
61
+ function isGraphqlStateManagerSpecifier(specifier) {
62
+ return specifier === "lightning/stateManagerGraphQL";
63
+ }
64
+ function buildStateManagerCompositionBody(name, cfg, specifier) {
65
+ if (isGraphqlStateManagerSpecifier(specifier)) {
66
+ const graphqlCfg = { mcp: { toolName: cfg.mcp?.toolName } };
67
+ return [
68
+ `import { ${cfg.factoryName} } from ${JSON.stringify(cfg.factoryModule)};`,
69
+ `const __getCommand_${name} = createGraphqlStateManagerCommand(${JSON.stringify(name)}, ${JSON.stringify(graphqlCfg)});`,
70
+ `export default ${cfg.factoryName}(__getCommand_${name});`
71
+ ].join("\n");
72
+ }
73
+ const synthesizedCfg = {
74
+ type: "imperative-read",
75
+ invokerShape: "legacy",
76
+ mcp: { toolName: cfg.mcp?.toolName },
77
+ configJsonSchema: cfg.configJsonSchema
78
+ };
79
+ return [
80
+ `import { ${cfg.factoryName} } from ${JSON.stringify(cfg.factoryModule)};`,
81
+ `const __cfg_${name} = ${JSON.stringify(synthesizedCfg)};`,
82
+ `const __imperativeAdapter_${name} = createReadAdapter(${JSON.stringify(name)}, __cfg_${name});`,
83
+ `export default ${cfg.factoryName}(__imperativeAdapter_${name});`
84
+ ].join("\n");
85
+ }
86
+ function parseImportSpecifiers(bracesContent) {
87
+ return bracesContent.split(",").map((s) => s.trim()).filter(Boolean).map((entry) => {
88
+ const asIdx = entry.indexOf(" as ");
89
+ const original = asIdx !== -1 ? entry.slice(0, asIdx).trim() : entry.trim();
90
+ return { original, full: entry };
91
+ });
92
+ }
11
93
  function stripTopLevelExports(source) {
12
94
  return source.replace(/^export\s+(?=(?:async\s+)?function\s)/gm, "").replace(/^export\s*\{[^}]*};?\s*$/gm, "");
13
95
  }
14
- const DEFAULT_ADAPTERS = {
96
+ const adapterBaseSource = stripTopLevelExports(
97
+ readFileSync(join(dirname(fileURLToPath(import.meta.url)), "runtime.js"), "utf-8")
98
+ );
99
+ const ADAPTER_PREFIX = "sf-lds-adapter:";
100
+ const ADAPTER_ID_PREFIX = "\0" + ADAPTER_PREFIX;
101
+ const DEFAULT_REGISTRY = {
15
102
  "lightning/uiRecordApi": {
16
103
  getRecord: {
17
104
  type: "wire",
18
- mcp: { toolName: "getRecordMcpTool" },
19
- configJsonSchema: {
20
- type: "object",
21
- properties: {
22
- recordId: { type: "string" },
23
- layoutTypes: {
24
- anyOf: [{ type: "array", items: { type: "string" } }, { type: "null" }]
25
- },
26
- fields: {
27
- anyOf: [{ type: "array", items: { type: "string" } }, { type: "null" }]
28
- }
29
- },
30
- required: ["recordId"],
31
- additionalProperties: false,
32
- anyOf: [
33
- {
34
- type: "object",
35
- properties: {
36
- fields: { type: "array", items: { type: "string" }, minItems: 1 }
37
- },
38
- required: ["fields"],
39
- additionalProperties: true
40
- },
41
- {
42
- type: "object",
43
- properties: {
44
- layoutTypes: {
45
- type: "array",
46
- items: { type: "string" },
47
- minItems: 1
48
- }
49
- },
50
- required: ["layoutTypes"],
51
- additionalProperties: true
52
- }
53
- ]
54
- }
105
+ mcp: { toolName: RECORD_TOOL },
106
+ configJsonSchema: RECORD_SCHEMA
55
107
  },
56
108
  createRecord: {
57
109
  type: "imperative-mutation",
@@ -97,15 +149,8 @@ const DEFAULT_ADAPTERS = {
97
149
  getObjectInfo_imperative: {
98
150
  type: "imperative-read",
99
151
  invokerShape: "legacy",
100
- mcp: { toolName: "getObjectInfoMcpTool" },
101
- configJsonSchema: {
102
- type: "object",
103
- properties: {
104
- objectApiName: { type: "string" }
105
- },
106
- required: ["objectApiName"],
107
- additionalProperties: false
108
- }
152
+ mcp: { toolName: OBJECT_INFO_TOOL },
153
+ configJsonSchema: OBJECT_INFO_SCHEMA
109
154
  }
110
155
  },
111
156
  // `lightning/graphql` — on-platform exports `gql`, the `graphql` wire
@@ -113,15 +158,70 @@ const DEFAULT_ADAPTERS = {
113
158
  // are registry entries; `gql` rides along automatically for any specifier
114
159
  // that has at least one graphql-typed entry (emitted by the load hook).
115
160
  "lightning/graphql": {
116
- graphql: { type: "graphql-wire", mcp: { toolName: "graphqlQuery" } },
117
- executeMutation: { type: "graphql-mutation", mcp: { toolName: "graphqlQuery" } }
161
+ graphql: { type: "graphql-wire", mcp: { toolName: GRAPHQL_TOOL } },
162
+ executeMutation: { type: "graphql-mutation", mcp: { toolName: GRAPHQL_TOOL } }
163
+ },
164
+ // `lightning/stateManagerGraphQL` — externalized graphql state manager.
165
+ // The load hook imports `createSmGraphQL` from the upstream
166
+ // `@salesforce/lds-adapters-onestore-graphql/factory` barrel — a thin
167
+ // per-state-manager wrapper around `createStateManager` that bakes in
168
+ // the required (`['query']`) / optional (`['variables', 'operationName']`)
169
+ // config keys, mirroring `createSmRecord` / `createSmObjectInfo`. The
170
+ // same factory wraps the call site on-core via `bindings/bindings.ts`,
171
+ // so off-core composition fidelity is preserved without on-core service
172
+ // plumbing leaking into this side.
173
+ //
174
+ // Per §10.3 the registry only ever has `default` as its key — the
175
+ // `createSmGraphQL` return value is itself the `default` export of
176
+ // the virtual module.
177
+ //
178
+ // `configJsonSchema` is omitted: off-core graphql forgoes the on-core
179
+ // `assertIsValid` / `resolveAndValidateGraphQLConfig` validation layer
180
+ // (§4 Non-goal 9), and the load-hook graphql path doesn't read the
181
+ // field anyway — malformed configs surface as MCP tool errors at
182
+ // execute time instead.
183
+ "lightning/stateManagerGraphQL": {
184
+ default: {
185
+ type: "state-manager",
186
+ factoryModule: "@salesforce/lds-adapters-onestore-graphql/factory",
187
+ factoryName: "createSmGraphQL",
188
+ mcp: { toolName: GRAPHQL_TOOL }
189
+ }
190
+ },
191
+ // State-manager specifier for ObjectInfo (spec §8.3 / §10.3). The load hook
192
+ // synthesizes a legacy-shape imperative-read adapter inline from
193
+ // (mcp.toolName, configJsonSchema) and feeds it to the upstream
194
+ // `createSmObjectInfo` factory. Reuses the shared `OBJECT_INFO_TOOL` /
195
+ // `OBJECT_INFO_SCHEMA` so this entry stays in lock-step with the
196
+ // `lightning/uiObjectInfoApi.getObjectInfo_imperative` entry above —
197
+ // both back the same UIAPI ObjectInfo MCP tool.
198
+ "lightning/stateManagerObjectInfo": {
199
+ default: {
200
+ type: "state-manager",
201
+ factoryModule: "@salesforce/state-managers-uiapi/factory",
202
+ factoryName: "createSmObjectInfo",
203
+ mcp: { toolName: OBJECT_INFO_TOOL },
204
+ configJsonSchema: OBJECT_INFO_SCHEMA
205
+ }
206
+ },
207
+ // `lightning/stateManagerRecord` — UIAPI Record state-manager. Per spec
208
+ // §10.3 the registry only ever has a single `default` key; the load hook
209
+ // synthesizes a legacy-shape imperative-read adapter from
210
+ // (mcp.toolName, configJsonSchema) and feeds it into the upstream
211
+ // `createSmRecord` factory to produce the externalized state manager.
212
+ // Reuses the shared `RECORD_TOOL` / `RECORD_SCHEMA` so the wire and
213
+ // state-manager paths stay anchored to a single MCP-tool / config
214
+ // contract.
215
+ "lightning/stateManagerRecord": {
216
+ default: {
217
+ type: "state-manager",
218
+ factoryModule: "@salesforce/state-managers-uiapi/factory",
219
+ factoryName: "createSmRecord",
220
+ mcp: { toolName: RECORD_TOOL },
221
+ configJsonSchema: RECORD_SCHEMA
222
+ }
118
223
  }
119
224
  };
120
- function isGraphqlSpecifier(moduleAdapters) {
121
- return Object.values(moduleAdapters).some(
122
- (entry) => entry.type === "graphql-wire" || entry.type === "graphql-mutation" || entry.type === "graphql-imperative-read"
123
- );
124
- }
125
225
  function factoryFor(type) {
126
226
  switch (type) {
127
227
  case "wire":
@@ -136,19 +236,14 @@ function factoryFor(type) {
136
236
  return "createGraphQLMutationAdapter";
137
237
  case "graphql-imperative-read":
138
238
  return "createGraphQLImperativeReadAdapter";
239
+ case "state-manager":
240
+ return "createStateManagerComposition";
139
241
  }
140
242
  }
141
- function parseImportSpecifiers(bracesContent) {
142
- return bracesContent.split(",").map((s) => s.trim()).filter(Boolean).map((entry) => {
143
- const asIdx = entry.indexOf(" as ");
144
- const original = asIdx !== -1 ? entry.slice(0, asIdx).trim() : entry.trim();
145
- return { original, full: entry };
146
- });
147
- }
148
243
  function mergeWithDefaults(overrides) {
149
- const merged = { ...DEFAULT_ADAPTERS };
244
+ const merged = { ...DEFAULT_REGISTRY };
150
245
  for (const [specifier, entries] of Object.entries(overrides)) {
151
- merged[specifier] = { ...DEFAULT_ADAPTERS[specifier] ?? {}, ...entries };
246
+ merged[specifier] = { ...DEFAULT_REGISTRY[specifier] ?? {}, ...entries };
152
247
  }
153
248
  return merged;
154
249
  }
@@ -157,9 +252,26 @@ function lds(overrides = {}) {
157
252
  const graphqlSpecifiers = new Set(
158
253
  Object.entries(adapters).filter(([, moduleAdapters]) => isGraphqlSpecifier(moduleAdapters)).map(([specifier]) => specifier)
159
254
  );
160
- const transformSpecifiers = Object.keys(adapters).filter((s) => !graphqlSpecifiers.has(s));
255
+ const stateManagerSpecifiers = new Set(
256
+ Object.entries(adapters).filter(([, moduleAdapters]) => isStateManagerSpecifier(moduleAdapters)).map(([specifier]) => specifier)
257
+ );
258
+ const transformSpecifiers = Object.keys(adapters).filter(
259
+ (s) => !graphqlSpecifiers.has(s) && !stateManagerSpecifiers.has(s)
260
+ );
161
261
  const specifierSnippets = transformSpecifiers.flatMap((s) => [`'${s}'`, `"${s}"`]);
162
- return {
262
+ const factoryModuleSpecifiers = /* @__PURE__ */ new Set();
263
+ for (const moduleAdapters of Object.values(adapters)) {
264
+ for (const entry of Object.values(moduleAdapters)) {
265
+ if (entry.type === "state-manager") {
266
+ factoryModuleSpecifiers.add(entry.factoryModule);
267
+ }
268
+ }
269
+ }
270
+ const passthroughRules = [...factoryModuleSpecifiers].map((specifier) => ({
271
+ specifierPrefix: specifier,
272
+ importerPattern: ADAPTER_PREFIX
273
+ }));
274
+ const plugin = {
163
275
  name: "vite-plugin-lds",
164
276
  enforce: "pre",
165
277
  async transform(code, id) {
@@ -207,7 +319,9 @@ function lds(overrides = {}) {
207
319
  return { code: s.toString(), map: s.generateMap({ hires: true }) };
208
320
  },
209
321
  resolveId(id) {
210
- if (graphqlSpecifiers.has(id)) return ADAPTER_ID_PREFIX + id;
322
+ if (graphqlSpecifiers.has(id) || stateManagerSpecifiers.has(id)) {
323
+ return ADAPTER_ID_PREFIX + id;
324
+ }
211
325
  if (id.startsWith(ADAPTER_PREFIX)) return ADAPTER_ID_PREFIX + id.slice(ADAPTER_PREFIX.length);
212
326
  return null;
213
327
  },
@@ -218,6 +332,10 @@ function lds(overrides = {}) {
218
332
  if (!moduleAdapters) return null;
219
333
  const lines = [adapterBaseSource];
220
334
  for (const [name, entry] of Object.entries(moduleAdapters)) {
335
+ if (entry.type === "state-manager") {
336
+ lines.push(buildStateManagerCompositionBody(name, entry, specifier));
337
+ continue;
338
+ }
221
339
  const { type, ...cfg } = entry;
222
340
  lines.push(
223
341
  `export const ${name} = ${factoryFor(type)}(${JSON.stringify(name)}, ${JSON.stringify(cfg)});`
@@ -229,6 +347,7 @@ function lds(overrides = {}) {
229
347
  return lines.join("\n");
230
348
  }
231
349
  };
350
+ return Object.assign(plugin, { passthroughRules });
232
351
  }
233
352
  export {
234
353
  lds
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/providers/lds/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 { JSONSchema } from \"@conduit-client/jsonschema-validate\";\nimport { init, parse } from \"es-module-lexer\";\nimport MagicString from \"magic-string\";\nimport type { Plugin } from \"vite\";\nimport type { ReadInvokerShape } from \"./types\";\n\n// prefix to write into transformed source code\nconst ADAPTER_PREFIX = \"sf-lds-adapter:\";\n// prefix used to ID the adapter when loading the virtual module\nconst ADAPTER_ID_PREFIX = \"\\0\" + ADAPTER_PREFIX;\n\n// the source of the adapter base module — reused across virtual modules so\n// each generated specifier emits the factories once.\n//\n// Top-level exports from the runtime module are stripped so every factory and\n// `gql` becomes a private binding inside the virtual module. The load hook\n// then controls exactly which names are exported per specifier: adapter\n// entries from the registry, plus `gql` for graphql specifiers. Without this,\n// the built `runtime.js` (trailing `export { …, gql, createWireAdapter, … }`)\n// and the source `runtime.ts` (per-declaration `export function gql …`) both\n// produce a `SyntaxError: Duplicate export of 'gql'` when the load hook also\n// appends `export { gql };`. They also leak the factory names as exports on\n// every LDS virtual module, which isn't a public contract we want.\nconst adapterBaseSource = stripTopLevelExports(\n\treadFileSync(join(dirname(fileURLToPath(import.meta.url)), \"runtime.js\"), \"utf-8\"),\n);\n\n/**\n * Removes top-level ES-module `export` keywords from the embedded runtime\n * source so its declarations survive as private bindings inside the virtual\n * module. Handles two shapes:\n * 1. Per-declaration: `export function foo …` / `export async function foo`\n * → the `export ` prefix is dropped.\n * 2. Trailing re-export clause: `export { foo, bar };` → deleted entirely.\n * Inner occurrences (inside function bodies, comments, strings) are not\n * affected because the source is a flat module with exports only at column 0.\n */\nfunction stripTopLevelExports(source: string): string {\n\treturn source\n\t\t.replace(/^export\\s+(?=(?:async\\s+)?function\\s)/gm, \"\")\n\t\t.replace(/^export\\s*\\{[^}]*};?\\s*$/gm, \"\");\n}\n\n/**\n * MCP dispatch descriptor. Nested under `mcp` on every adapter config so\n * additional MCP-specific fields (auth, transport, retry policy) can join\n * later without reshaping every consumer entry.\n */\nexport interface LdsAdapterMcpDispatch {\n\ttoolName: string;\n}\n\n/**\n * Base shape every LDS adapter config extends. Holds the dispatch surface in\n * one place so new backings (e.g. `http`) can land as sibling optional fields\n * without forking each adapter interface. Dual registration is supported at\n * the type level — runtime execution still targets a single backing per call.\n */\nexport interface LdsAdapterConfigBase {\n\tmcp?: LdsAdapterMcpDispatch;\n}\n\n/**\n * LDS adapter configs whose input is validated against a JSON Schema at\n * invoke time — wire, imperative-mutation, imperative-read. GraphQL variants\n * skip this base because they pass `{ query, variables }` through to the\n * configured MCP tool with no schema check.\n */\nexport interface LdsSchemaValidatedAdapterConfig extends LdsAdapterConfigBase {\n\tconfigJsonSchema: JSONSchema;\n}\n\nexport interface LdsWireAdapterConfig extends LdsSchemaValidatedAdapterConfig {\n\ttype: \"wire\";\n}\n\n/**\n * Imperative **mutation** adapter. Always an async\n * `(config) => Promise<Data>` that throws on validation or tool error —\n * matching OneStore's `DefaultImperativeBindingsService`, the only service a\n * mutation ever uses on platform. Mutations do not carry an `invokerShape`:\n * `subscribe`/`refresh` make no sense on write, and allowing them here\n * would drift off-platform from on-platform semantics.\n */\nexport interface LdsImperativeMutationAdapterConfig extends LdsSchemaValidatedAdapterConfig {\n\ttype: \"imperative-mutation\";\n}\n\n/**\n * Public alias for the read-shape union defined in `runtime.ts`. Re-exported\n * from this module so consumers don't have to import from the runtime entry\n * point, while keeping the union pinned to one source of truth.\n *\n * Off-platform there is no store, so `subscribe` is a deliberate no-op\n * (callback never fires, returned unsubscribe is idempotent) and `refresh`\n * re-executes the underlying MCP tool. This preserves the OneStore API\n * surface for code ported verbatim.\n */\nexport type LdsImperativeReadInvokerShape = ReadInvokerShape;\n\nexport interface LdsImperativeReadAdapterConfig extends LdsSchemaValidatedAdapterConfig {\n\ttype: \"imperative-read\";\n\tinvokerShape: LdsImperativeReadInvokerShape;\n}\n\n/**\n * GraphQL wire adapter. Emits `{ data, errors, refresh }` (distinct from the\n * base wire `{ data, error }`). No `configJsonSchema` — the adapter passes\n * `{ query, variables }` through to the configured MCP tool.\n */\nexport interface LdsGraphqlWireAdapterConfig extends LdsAdapterConfigBase {\n\ttype: \"graphql-wire\";\n}\n\n/**\n * Imperative GraphQL mutation — `(config) => Promise<{ data, errors }>`.\n * Errors are routed in-band to the `errors[]` envelope rather than thrown,\n * matching on-platform `toGraphQLResponseFromFailure`.\n */\nexport interface LdsGraphqlMutationAdapterConfig extends LdsAdapterConfigBase {\n\ttype: \"graphql-mutation\";\n}\n\n/**\n * Read-shape discriminator for imperative GraphQL adapters. Mirrors the\n * `imperative-read` `invokerShape` field so the two families share a pattern:\n * one `type` discriminator + a shape field that selects the return surface.\n *\n * - `query` — `Promise<{ data, errors, subscribe }>` (on-platform\n * `GraphQLImperativeBindingsService` without `exposeRefresh`).\n * - `query-refreshable` — `Promise<{ data, errors, subscribe, refresh }>`\n * (same service with `exposeRefresh: true`).\n * - `legacy` — `{ invoke(config, context, callback),\n * subscribe(config, context, callback): Unsubscribe }`, the older callback\n * surface served by `GraphQLLegacyImperativeBindingsService`.\n *\n * `subscribe` is a deliberate no-op off-platform (no reactive store).\n */\nexport type LdsGraphqlImperativeReadInvokerShape = \"query\" | \"query-refreshable\" | \"legacy\";\n\n/**\n * Imperative GraphQL read adapter. The `invokerShape` picks the return\n * surface — see {@link LdsGraphqlImperativeReadInvokerShape}. Errors are\n * routed in-band to `errors[]` (for `query`/`query-refreshable`) or into the\n * callback payload (for `legacy`); no shape throws on tool errors.\n */\nexport interface LdsGraphqlImperativeReadAdapterConfig extends LdsAdapterConfigBase {\n\ttype: \"graphql-imperative-read\";\n\tinvokerShape: LdsGraphqlImperativeReadInvokerShape;\n}\n\nexport type LdsAdapterConfig =\n\t| LdsWireAdapterConfig\n\t| LdsImperativeMutationAdapterConfig\n\t| LdsImperativeReadAdapterConfig\n\t| LdsGraphqlWireAdapterConfig\n\t| LdsGraphqlMutationAdapterConfig\n\t| LdsGraphqlImperativeReadAdapterConfig;\n\nexport type LdsAdapterRegistry = Record<string, Record<string, LdsAdapterConfig>>;\n\n/**\n * Default adapter registry.\n * Maps LDS module specifiers to MCP tool-backed implementations. Entries can be\n * wire adapters (`type: 'wire'`), imperative mutations (`type: 'imperative-mutation'`),\n * or imperative reads (`type: 'imperative-read'` + `invokerShape`).\n * Add entries here to support additional lightning/* exports.\n */\nconst DEFAULT_ADAPTERS: LdsAdapterRegistry = {\n\t\"lightning/uiRecordApi\": {\n\t\tgetRecord: {\n\t\t\ttype: \"wire\",\n\t\t\tmcp: { toolName: \"getRecordMcpTool\" },\n\t\t\tconfigJsonSchema: {\n\t\t\t\ttype: \"object\",\n\t\t\t\tproperties: {\n\t\t\t\t\trecordId: { type: \"string\" },\n\t\t\t\t\tlayoutTypes: {\n\t\t\t\t\t\tanyOf: [{ type: \"array\", items: { type: \"string\" } }, { type: \"null\" }],\n\t\t\t\t\t},\n\t\t\t\t\tfields: {\n\t\t\t\t\t\tanyOf: [{ type: \"array\", items: { type: \"string\" } }, { type: \"null\" }],\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\trequired: [\"recordId\"],\n\t\t\t\tadditionalProperties: false,\n\t\t\t\tanyOf: [\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: \"object\",\n\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\tfields: { type: \"array\", items: { type: \"string\" }, minItems: 1 },\n\t\t\t\t\t\t},\n\t\t\t\t\t\trequired: [\"fields\"],\n\t\t\t\t\t\tadditionalProperties: true,\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: \"object\",\n\t\t\t\t\t\tproperties: {\n\t\t\t\t\t\t\tlayoutTypes: {\n\t\t\t\t\t\t\t\ttype: \"array\",\n\t\t\t\t\t\t\t\titems: { type: \"string\" },\n\t\t\t\t\t\t\t\tminItems: 1,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\trequired: [\"layoutTypes\"],\n\t\t\t\t\t\tadditionalProperties: true,\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t},\n\t\tcreateRecord: {\n\t\t\ttype: \"imperative-mutation\",\n\t\t\tmcp: { toolName: \"createRecordMcpTool\" },\n\t\t\tconfigJsonSchema: {\n\t\t\t\ttype: \"object\",\n\t\t\t\tproperties: {\n\t\t\t\t\tapiName: { type: \"string\" },\n\t\t\t\t\tfields: {\n\t\t\t\t\t\ttype: \"object\",\n\t\t\t\t\t\tproperties: {},\n\t\t\t\t\t\trequired: [],\n\t\t\t\t\t\tadditionalProperties: true,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\trequired: [\"apiName\", \"fields\"],\n\t\t\t\tadditionalProperties: false,\n\t\t\t},\n\t\t},\n\t\tupdateRecord: {\n\t\t\ttype: \"imperative-mutation\",\n\t\t\tmcp: { toolName: \"updateRecordMcpTool\" },\n\t\t\tconfigJsonSchema: {\n\t\t\t\ttype: \"object\",\n\t\t\t\tproperties: {\n\t\t\t\t\trecordId: { type: \"string\" },\n\t\t\t\t\tfields: {\n\t\t\t\t\t\ttype: \"object\",\n\t\t\t\t\t\tproperties: {},\n\t\t\t\t\t\trequired: [],\n\t\t\t\t\t\tadditionalProperties: true,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\trequired: [\"recordId\", \"fields\"],\n\t\t\t\tadditionalProperties: false,\n\t\t\t},\n\t\t},\n\t},\n\t\"lightning/uiObjectInfoApi\": {\n\t\t// On-platform this is a `{ invoke, subscribe }` callback surface\n\t\t// emitting `{ data, error }`. The legacy invoker shape preserves that\n\t\t// contract verbatim, so ported consumers keep their call sites.\n\t\tgetObjectInfo_imperative: {\n\t\t\ttype: \"imperative-read\",\n\t\t\tinvokerShape: \"legacy\",\n\t\t\tmcp: { toolName: \"getObjectInfoMcpTool\" },\n\t\t\tconfigJsonSchema: {\n\t\t\t\ttype: \"object\",\n\t\t\t\tproperties: {\n\t\t\t\t\tobjectApiName: { type: \"string\" },\n\t\t\t\t},\n\t\t\t\trequired: [\"objectApiName\"],\n\t\t\t\tadditionalProperties: false,\n\t\t\t},\n\t\t},\n\t},\n\t// `lightning/graphql` — on-platform exports `gql`, the `graphql` wire\n\t// adapter, and `executeMutation`. Only `graphql` and `executeMutation`\n\t// are registry entries; `gql` rides along automatically for any specifier\n\t// that has at least one graphql-typed entry (emitted by the load hook).\n\t\"lightning/graphql\": {\n\t\tgraphql: { type: \"graphql-wire\", mcp: { toolName: \"graphqlQuery\" } },\n\t\texecuteMutation: { type: \"graphql-mutation\", mcp: { toolName: \"graphqlQuery\" } },\n\t},\n};\n\n/** True when any entry in a module's adapter map is a `graphql-*` type. */\nfunction isGraphqlSpecifier(moduleAdapters: Record<string, LdsAdapterConfig>): boolean {\n\treturn Object.values(moduleAdapters).some(\n\t\t(entry) =>\n\t\t\tentry.type === \"graphql-wire\" ||\n\t\t\tentry.type === \"graphql-mutation\" ||\n\t\t\tentry.type === \"graphql-imperative-read\",\n\t);\n}\n\n/** Maps a config discriminator to the factory name emitted in the virtual module. */\nfunction factoryFor(type: LdsAdapterConfig[\"type\"]): string {\n\tswitch (type) {\n\t\tcase \"wire\":\n\t\t\treturn \"createWireAdapter\";\n\t\tcase \"imperative-mutation\":\n\t\t\treturn \"createMutationAdapter\";\n\t\tcase \"imperative-read\":\n\t\t\treturn \"createReadAdapter\";\n\t\tcase \"graphql-wire\":\n\t\t\treturn \"createGraphQLWireAdapter\";\n\t\tcase \"graphql-mutation\":\n\t\t\treturn \"createGraphQLMutationAdapter\";\n\t\tcase \"graphql-imperative-read\":\n\t\t\treturn \"createGraphQLImperativeReadAdapter\";\n\t}\n}\n\nfunction parseImportSpecifiers(bracesContent: string): { original: string; full: string }[] {\n\treturn bracesContent\n\t\t.split(\",\")\n\t\t.map((s) => s.trim())\n\t\t.filter(Boolean)\n\t\t.map((entry) => {\n\t\t\tconst asIdx = entry.indexOf(\" as \");\n\t\t\tconst original = asIdx !== -1 ? entry.slice(0, asIdx).trim() : entry.trim();\n\t\t\treturn { original, full: entry };\n\t\t});\n}\n\n/**\n * Deep-merges user overrides onto the default registry: every specifier from\n * both sides is preserved, and per-specifier entries are merged so a consumer\n * can override `getRecord` without losing `createRecord`, or register a new\n * entry on `lightning/graphql` without losing `graphql` / `executeMutation`.\n * Pass an empty object to get just the defaults. To opt out of a default\n * entry, pass the same specifier with a different entry of the same key.\n */\nfunction mergeWithDefaults(overrides: LdsAdapterRegistry): LdsAdapterRegistry {\n\tconst merged: LdsAdapterRegistry = { ...DEFAULT_ADAPTERS };\n\tfor (const [specifier, entries] of Object.entries(overrides)) {\n\t\tmerged[specifier] = { ...(DEFAULT_ADAPTERS[specifier] ?? {}), ...entries };\n\t}\n\treturn merged;\n}\n\n/**\n * LDS provider — rewrites registered `lightning/*` imports (e.g.\n * `lightning/uiRecordApi`) to MCP-tool-backed virtual modules. Unregistered\n * exports pass through to the normal `lightning/*` resolution.\n *\n * Three Vite hooks do the work:\n *\n * - **`transform`** — parses each `.js` / `.ts` file with `es-module-lexer`,\n * finds named imports from registered specifiers, and rewrites them to pull\n * registered names from `sf-lds-adapter:<specifier>` while leaving\n * unregistered names pointing at the original specifier.\n *\n * - **`resolveId`** — maps `sf-lds-adapter:<specifier>` to a `\\0`-prefixed\n * virtual module ID, preventing Rollup from attempting a filesystem lookup.\n *\n * - **`load`** — generates the virtual module, emitting an MCP-backed\n * `createWireAdapter(...)` class for every `type: 'wire'` entry,\n * `createMutationAdapter(...)` for every `type: 'imperative-mutation'` entry,\n * and `createReadAdapter(...)` for every `type: 'imperative-read'` entry.\n *\n * Only specifiers present in the `adapters` registry are intercepted; imports from\n * unregistered specifiers pass through unchanged.\n */\nexport function lds(overrides: LdsAdapterRegistry = {}): Plugin {\n\tconst adapters = mergeWithDefaults(overrides);\n\t// Graphql specifiers are owned whole by the virtual module — every export\n\t// (adapters + `gql`) lives there, so the transform hook should not split\n\t// their imports. Non-graphql specifiers still go through transform so\n\t// unregistered names pass through to the real `lightning/*` module.\n\tconst graphqlSpecifiers = new Set<string>(\n\t\tObject.entries(adapters)\n\t\t\t.filter(([, moduleAdapters]) => isGraphqlSpecifier(moduleAdapters))\n\t\t\t.map(([specifier]) => specifier),\n\t);\n\tconst transformSpecifiers = Object.keys(adapters).filter((s) => !graphqlSpecifiers.has(s));\n\tconst specifierSnippets = transformSpecifiers.flatMap((s) => [`'${s}'`, `\"${s}\"`]);\n\n\treturn {\n\t\tname: \"vite-plugin-lds\",\n\t\tenforce: \"pre\",\n\n\t\tasync transform(code, id) {\n\t\t\tconst cleanId = id.split(\"?\")[0] ?? id;\n\t\t\tif (!cleanId.endsWith(\".js\") && !cleanId.endsWith(\".ts\")) return null;\n\t\t\tif (cleanId.includes(\"/node_modules/\")) return null;\n\t\t\tif (!specifierSnippets.some((snippet) => code.includes(snippet))) return null;\n\n\t\t\tawait init;\n\n\t\t\tlet imports: ReturnType<typeof parse>[0];\n\t\t\ttry {\n\t\t\t\t[imports] = parse(code);\n\t\t\t} catch {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tconst relevant = imports.filter(\n\t\t\t\t(imp) =>\n\t\t\t\t\timp.d === -1 && imp.n !== undefined && imp.n in adapters && !graphqlSpecifiers.has(imp.n),\n\t\t\t);\n\t\t\tif (relevant.length === 0) return null;\n\n\t\t\tconst s = new MagicString(code);\n\t\t\tlet changed = false;\n\n\t\t\tfor (const imp of relevant) {\n\t\t\t\tconst { ss: start, se: end, n: specifier } = imp;\n\t\t\t\tconst statement = code.slice(start, end);\n\n\t\t\t\tconst openBrace = statement.indexOf(\"{\");\n\t\t\t\tconst closeBrace = statement.indexOf(\"}\");\n\t\t\t\tif (openBrace === -1 || closeBrace === -1) continue;\n\n\t\t\t\tconst bracesContent = statement.slice(openBrace + 1, closeBrace);\n\t\t\t\tconst moduleAdapters = adapters[specifier!]!;\n\t\t\t\tconst parsedImport = parseImportSpecifiers(bracesContent);\n\t\t\t\tconst registered = parsedImport.filter((p) => p.original in moduleAdapters);\n\t\t\t\tconst unregistered = parsedImport.filter((p) => !(p.original in moduleAdapters));\n\n\t\t\t\tif (registered.length === 0) continue;\n\n\t\t\t\tconst parts: string[] = [\n\t\t\t\t\t`import { ${registered.map((p) => p.full).join(\", \")} } from '${ADAPTER_PREFIX}${specifier}';`,\n\t\t\t\t];\n\n\t\t\t\tif (unregistered.length > 0) {\n\t\t\t\t\tparts.push(\n\t\t\t\t\t\t`import { ${unregistered.map((p) => p.full).join(\", \")} } from '${specifier}';`,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\ts.overwrite(start, end, parts.join(\"\\n\"));\n\t\t\t\tchanged = true;\n\t\t\t}\n\n\t\t\tif (!changed) return null;\n\t\t\treturn { code: s.toString(), map: s.generateMap({ hires: true }) };\n\t\t},\n\n\t\tresolveId(id) {\n\t\t\t// Graphql specifiers are intercepted raw — no transform hook split\n\t\t\t// — and mapped into the same `\\0sf-lds-adapter:` virtual namespace\n\t\t\t// so the load hook emits one module per specifier.\n\t\t\tif (graphqlSpecifiers.has(id)) return ADAPTER_ID_PREFIX + id;\n\t\t\tif (id.startsWith(ADAPTER_PREFIX)) return ADAPTER_ID_PREFIX + id.slice(ADAPTER_PREFIX.length);\n\t\t\treturn null;\n\t\t},\n\n\t\tload(id) {\n\t\t\tif (!id.startsWith(ADAPTER_ID_PREFIX)) return null;\n\n\t\t\tconst specifier = id.slice(ADAPTER_ID_PREFIX.length);\n\t\t\tconst moduleAdapters = adapters[specifier];\n\t\t\tif (!moduleAdapters) return null;\n\n\t\t\t// create lines of code used to create MCP tool based adapters\n\t\t\tconst lines: string[] = [adapterBaseSource];\n\t\t\tfor (const [name, entry] of Object.entries(moduleAdapters)) {\n\t\t\t\tconst { type, ...cfg } = entry;\n\t\t\t\tlines.push(\n\t\t\t\t\t`export const ${name} = ${factoryFor(type)}(${JSON.stringify(name)}, ${JSON.stringify(cfg)});`,\n\t\t\t\t);\n\t\t\t}\n\t\t\t// `gql` rides along with any specifier that declares a graphql\n\t\t\t// adapter, so `import { gql } from 'lightning/graphql'` (or any\n\t\t\t// aliased form) keeps resolving even when no adapters are\n\t\t\t// imported alongside it. The binding itself is a private function\n\t\t\t// inside `adapterBaseSource` after `stripTopLevelExports`.\n\t\t\tif (graphqlSpecifiers.has(specifier)) {\n\t\t\t\tlines.push(\"export { gql };\");\n\t\t\t}\n\t\t\treturn lines.join(\"\\n\");\n\t\t},\n\t};\n}\n"],"names":[],"mappings":";;;;;AAeA,MA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IAAI,CAAC,KAAK,KAAK,UAAU,GAAG,CAAC;AAAA,QAAA;AAAA,MAE5F;AAMA,UAAI,kBAAkB,IAAI,SAAS,GAAG;AACrC,cAAM,KAAK,iBAAiB;AAAA,MAC7B;AACA,aAAO,MAAM,KAAK,IAAI;AAAA,IACvB;AAAA,EAAA;AAEF;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/providers/lds/adapters.ts","../../../src/providers/lds/common-mcp-tooling.ts","../../../src/providers/lds/state-managers.ts","../../../src/providers/lds/util.ts","../../../src/providers/lds/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 type {\n\tLdsRegistryEntry,\n\tLdsRegistryEntryBase,\n\tLdsSchemaValidatedEntry,\n} from \"./common-mcp-tooling\";\nimport type { ReadInvokerShape } from \"./types\";\n\n// ─── Wire + imperative adapter configs ───────────────────────────────────────\n\nexport interface LdsWireAdapterConfig extends LdsSchemaValidatedEntry {\n\ttype: \"wire\";\n}\n\n/**\n * Imperative **mutation** adapter. Always an async\n * `(config) => Promise<Data>` that throws on validation or tool error —\n * matching OneStore's `DefaultImperativeBindingsService`, the only service a\n * mutation ever uses on platform. Mutations do not carry an `invokerShape`:\n * `subscribe`/`refresh` make no sense on write, and allowing them here\n * would drift off-platform from on-platform semantics.\n */\nexport interface LdsImperativeMutationAdapterConfig extends LdsSchemaValidatedEntry {\n\ttype: \"imperative-mutation\";\n}\n\n/**\n * Public alias for the read-shape union defined in `runtime.ts`. Re-exported\n * from this module so consumers don't have to import from the runtime entry\n * point, while keeping the union pinned to one source of truth.\n *\n * Off-platform there is no store, so `subscribe` is a deliberate no-op\n * (callback never fires, returned unsubscribe is idempotent) and `refresh`\n * re-executes the underlying MCP tool. This preserves the OneStore API\n * surface for code ported verbatim.\n */\nexport type LdsImperativeReadInvokerShape = ReadInvokerShape;\n\nexport interface LdsImperativeReadAdapterConfig extends LdsSchemaValidatedEntry {\n\ttype: \"imperative-read\";\n\tinvokerShape: LdsImperativeReadInvokerShape;\n}\n\n// ─── GraphQL adapter configs ─────────────────────────────────────────────────\n\n/**\n * GraphQL wire adapter. Emits `{ data, errors, refresh }` (distinct from the\n * base wire `{ data, error }`). No `configJsonSchema` — the adapter passes\n * `{ query, variables }` through to the configured MCP tool.\n */\nexport interface LdsGraphqlWireAdapterConfig extends LdsRegistryEntryBase {\n\ttype: \"graphql-wire\";\n}\n\n/**\n * Imperative GraphQL mutation — `(config) => Promise<{ data, errors }>`.\n * Errors are routed in-band to the `errors[]` envelope rather than thrown,\n * matching on-platform `toGraphQLResponseFromFailure`.\n */\nexport interface LdsGraphqlMutationAdapterConfig extends LdsRegistryEntryBase {\n\ttype: \"graphql-mutation\";\n}\n\n/**\n * Read-shape discriminator for imperative GraphQL adapters. Mirrors the\n * `imperative-read` `invokerShape` field so the two families share a pattern:\n * one `type` discriminator + a shape field that selects the return surface.\n *\n * - `query` — `Promise<{ data, errors, subscribe }>` (on-platform\n * `GraphQLImperativeBindingsService` without `exposeRefresh`).\n * - `query-refreshable` — `Promise<{ data, errors, subscribe, refresh }>`\n * (same service with `exposeRefresh: true`).\n * - `legacy` — `{ invoke(config, context, callback),\n * subscribe(config, context, callback): Unsubscribe }`, the older callback\n * surface served by `GraphQLLegacyImperativeBindingsService`.\n *\n * `subscribe` is a deliberate no-op off-platform (no reactive store).\n */\nexport type LdsGraphqlImperativeReadInvokerShape = \"query\" | \"query-refreshable\" | \"legacy\";\n\n/**\n * Imperative GraphQL read adapter. The `invokerShape` picks the return\n * surface — see {@link LdsGraphqlImperativeReadInvokerShape}. Errors are\n * routed in-band to `errors[]` (for `query`/`query-refreshable`) or into the\n * callback payload (for `legacy`); no shape throws on tool errors.\n */\nexport interface LdsGraphqlImperativeReadAdapterConfig extends LdsRegistryEntryBase {\n\ttype: \"graphql-imperative-read\";\n\tinvokerShape: LdsGraphqlImperativeReadInvokerShape;\n}\n\n// ─── Load-hook helpers (non-state-manager paths) ─────────────────────────────\n\n/** True when any entry in a module's registry map is a `graphql-*` type. */\nexport function isGraphqlSpecifier(moduleAdapters: Record<string, LdsRegistryEntry>): boolean {\n\treturn Object.values(moduleAdapters).some(\n\t\t(entry) =>\n\t\t\tentry.type === \"graphql-wire\" ||\n\t\t\tentry.type === \"graphql-mutation\" ||\n\t\t\tentry.type === \"graphql-imperative-read\",\n\t);\n}\n","/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport type { JSONSchema } from \"@conduit-client/jsonschema-validate\";\nimport type {\n\tLdsGraphqlImperativeReadAdapterConfig,\n\tLdsGraphqlMutationAdapterConfig,\n\tLdsGraphqlWireAdapterConfig,\n\tLdsImperativeMutationAdapterConfig,\n\tLdsImperativeReadAdapterConfig,\n\tLdsWireAdapterConfig,\n} from \"./adapters\";\nimport type { LdsStateManagerConfig } from \"./state-managers\";\n\n// ─── Base shapes shared by every MCP-backed registry entry ───────────────────\n\n/**\n * MCP dispatch descriptor. Nested under `mcp` on every registry entry so\n * additional MCP-specific fields (auth, transport, retry policy) can join\n * later without reshaping every consumer entry.\n */\nexport interface LdsMcpDispatch {\n\ttoolName: string;\n}\n\n/**\n * Base shape every LDS registry entry extends. Holds the dispatch surface in\n * one place so new backings (e.g. `http`) can land as sibling optional fields\n * without forking each entry interface. Dual registration is supported at\n * the type level — runtime execution still targets a single backing per call.\n */\nexport interface LdsRegistryEntryBase {\n\tmcp?: LdsMcpDispatch;\n}\n\n/**\n * LDS registry entries whose input is validated against a JSON Schema at\n * invoke time — wire, imperative-mutation, imperative-read. GraphQL variants\n * skip this base because they pass `{ query, variables }` through to the\n * configured MCP tool with no schema check.\n */\nexport interface LdsSchemaValidatedEntry extends LdsRegistryEntryBase {\n\tconfigJsonSchema: JSONSchema;\n}\n\n// ─── Public union + registry surface ─────────────────────────────────────────\n// Lives in `common-mcp-tooling` because the union is the \"what kinds of\n// MCP-backed things exist\" summary every consumer reaches for. The union\n// spans both adapter variants (wire / imperative / graphql) and the\n// state-manager variant since they share the same registry slot — even\n// though state managers aren't technically adapters.\n\nexport type LdsRegistryEntry =\n\t| LdsWireAdapterConfig\n\t| LdsImperativeMutationAdapterConfig\n\t| LdsImperativeReadAdapterConfig\n\t| LdsGraphqlWireAdapterConfig\n\t| LdsGraphqlMutationAdapterConfig\n\t| LdsGraphqlImperativeReadAdapterConfig\n\t| LdsStateManagerConfig;\n\nexport type LdsRegistry = Record<string, Record<string, LdsRegistryEntry>>;\n\n// ─── Per-resource shared MCP-tool constants ──────────────────────────────────\n// Tool names and JSON Schemas extracted from the registry so wire / imperative\n// siblings backed by the same MCP tool reference one source of truth. Mutation\n// adapters keep their own dedicated tools and schemas because their dispatch\n// surface is distinct (different tool name, different validated input).\n\nexport const RECORD_TOOL = \"getRecordMcpTool\";\nexport const RECORD_SCHEMA: JSONSchema = {\n\ttype: \"object\",\n\tproperties: {\n\t\trecordId: { type: \"string\" },\n\t\tlayoutTypes: {\n\t\t\tanyOf: [{ type: \"array\", items: { type: \"string\" } }, { type: \"null\" }],\n\t\t},\n\t\tfields: {\n\t\t\tanyOf: [{ type: \"array\", items: { type: \"string\" } }, { type: \"null\" }],\n\t\t},\n\t},\n\trequired: [\"recordId\"],\n\tadditionalProperties: false,\n\tanyOf: [\n\t\t{\n\t\t\ttype: \"object\",\n\t\t\tproperties: {\n\t\t\t\tfields: { type: \"array\", items: { type: \"string\" }, minItems: 1 },\n\t\t\t},\n\t\t\trequired: [\"fields\"],\n\t\t\tadditionalProperties: true,\n\t\t},\n\t\t{\n\t\t\ttype: \"object\",\n\t\t\tproperties: {\n\t\t\t\tlayoutTypes: {\n\t\t\t\t\ttype: \"array\",\n\t\t\t\t\titems: { type: \"string\" },\n\t\t\t\t\tminItems: 1,\n\t\t\t\t},\n\t\t\t},\n\t\t\trequired: [\"layoutTypes\"],\n\t\t\tadditionalProperties: true,\n\t\t},\n\t],\n};\n\nexport const OBJECT_INFO_TOOL = \"getObjectInfoMcpTool\";\nexport const OBJECT_INFO_SCHEMA: JSONSchema = {\n\ttype: \"object\",\n\tproperties: {\n\t\tobjectApiName: { type: \"string\" },\n\t},\n\trequired: [\"objectApiName\"],\n\tadditionalProperties: false,\n};\n\nexport const GRAPHQL_TOOL = \"graphqlQuery\";\n","/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport type { JSONSchema } from \"@conduit-client/jsonschema-validate\";\nimport type { LdsRegistryEntry, LdsRegistryEntryBase } from \"./common-mcp-tooling\";\n\n/**\n * State-manager registry entry. The lds plugin's load hook emits a\n * factory-composition body for each state-manager entry — see\n * `buildStateManagerCompositionBody` below. Two emit shapes:\n *\n * - **UIAPI** (`lightning/stateManagerRecord`, `…ObjectInfo`) — synthesizes\n * a legacy-shape imperative-read adapter inline via `createReadAdapter`\n * and feeds it into the upstream per-state-manager factory\n * (`createSmRecord` / `createSmObjectInfo`) re-exported from\n * `@salesforce/state-managers-uiapi/factory`.\n *\n * - **GraphQL** (`lightning/stateManagerGraphQL`) — calls the upstream\n * per-state-manager factory `createSmGraphQL` re-exported from\n * `@salesforce/lds-adapters-onestore-graphql/factory` with an MCP-backed\n * `getCommand` synthesized via `createGraphqlStateManagerCommand`\n * (a `runtime.ts` helper). The required / optional config keys\n * (`['query']`, `['variables', 'operationName']`) live in the upstream\n * factory — a fixed contract of `lightning/stateManagerGraphQL` — so the\n * load-hook emit doesn't pass them. Mirrors the UIAPI shape (one\n * factory call, adapter argument only).\n *\n * Per-state-manager metadata (definedBy, requiredKeys, optionalKeys,\n * predicate) lives in the upstream factory — not here. See spec §8.4 / §10.4.\n *\n * `configJsonSchema` is optional: UIAPI state managers supply it (the\n * load hook embeds it in the synthesized imperative-read adapter), but\n * the graphql state-manager path doesn't read it (off-core graphql\n * forgoes the on-core `assertIsValid` / `resolveAndValidateGraphQLConfig`\n * validation layer; spec §4 Non-goal 9 — malformed configs surface as\n * MCP tool errors at execute time instead).\n */\nexport interface LdsStateManagerConfig extends LdsRegistryEntryBase {\n\ttype: \"state-manager\";\n\t/** Upstream factory specifier — e.g. '@salesforce/state-managers-uiapi/factory'. */\n\tfactoryModule: string;\n\t/** Named export within `factoryModule` — e.g. 'createSmRecord' (UIAPI), 'createSmGraphQL' (graphql). */\n\tfactoryName: string;\n\t/** JSON Schema for the config object — required for UIAPI state managers, omitted for graphql. */\n\tconfigJsonSchema?: JSONSchema;\n}\n\n/** True when any entry in a module's registry map is a `state-manager` type. */\nexport function isStateManagerSpecifier(moduleAdapters: Record<string, LdsRegistryEntry>): boolean {\n\treturn Object.values(moduleAdapters).some((entry) => entry.type === \"state-manager\");\n}\n\n/**\n * True when a state-manager specifier resolves to the graphql state manager\n * (`lightning/stateManagerGraphQL`). Used by `buildStateManagerCompositionBody`\n * to pick which emit shape to use:\n *\n * - GraphQL — call upstream `createSmGraphQL` with an MCP-backed\n * `getCommand` from `createGraphqlStateManagerCommand`. Required/optional\n * key sets (`['query']` / `['variables', 'operationName']`) live in the\n * upstream factory; the load-hook emit doesn't pass them.\n * - UIAPI — synthesize a legacy-shape imperative-read adapter inline via\n * `createReadAdapter` and feed it into the per-state-manager wrapper\n * (`createSmRecord` / `createSmObjectInfo`).\n *\n * Selecting on the specifier (rather than the registry entry's `type`)\n * mirrors §8.4 of the spec and keeps the `LdsStateManagerConfig` surface\n * free of an inner discriminator — consumers add a state-manager registry\n * entry once and the plugin picks the right emit shape.\n */\nfunction isGraphqlStateManagerSpecifier(specifier: string): boolean {\n\treturn specifier === \"lightning/stateManagerGraphQL\";\n}\n\n/**\n * Builds the §8.4 factory-composition body for a single `state-manager`\n * registry entry. Two emit shapes, gated by `isGraphqlStateManagerSpecifier`:\n *\n * **UIAPI shape** — `lightning/stateManagerRecord`, `…ObjectInfo`:\n * 1. Imports `<factoryName>` (e.g. `createSmRecord`) from the registry's\n * `factoryModule` (e.g. `@salesforce/state-managers-uiapi/factory`).\n * 2. Builds a legacy-shape imperative-read config and synthesizes the\n * adapter inline via `createReadAdapter` — a private binding pulled\n * into scope by `adapterBaseSource`.\n * 3. Default-exports `<factoryName>(synthesizedAdapter)`.\n *\n * **GraphQL shape** — `lightning/stateManagerGraphQL`:\n * 1. Imports `<factoryName>` (`createSmGraphQL`) from the registry's\n * `factoryModule` (`@salesforce/lds-adapters-onestore-graphql/factory`).\n * 2. Synthesizes an MCP-backed `getCommand` via `createGraphqlStateManagerCommand`\n * (a `runtime.ts` helper, in scope as a private binding).\n * 3. Default-exports `<factoryName>(getCommand)`. The required / optional\n * config keys are baked into the upstream factory, not passed here.\n *\n * Only `default` is exported in either shape. The upstream `<name>_internal`\n * named export (used internally by `state-managers-uiapi` for\n * cross-state-manager wiring and tests) is deliberately not re-exported —\n * uplifted customer LWCs only consume the default. See spec §8.4 / §10.4.\n */\nexport function buildStateManagerCompositionBody(\n\tname: string,\n\tcfg: LdsStateManagerConfig,\n\tspecifier: string,\n): string {\n\tif (isGraphqlStateManagerSpecifier(specifier)) {\n\t\tconst graphqlCfg = { mcp: { toolName: cfg.mcp?.toolName } };\n\t\treturn [\n\t\t\t`import { ${cfg.factoryName} } from ${JSON.stringify(cfg.factoryModule)};`,\n\t\t\t`const __getCommand_${name} = createGraphqlStateManagerCommand(${JSON.stringify(name)}, ${JSON.stringify(graphqlCfg)});`,\n\t\t\t`export default ${cfg.factoryName}(__getCommand_${name});`,\n\t\t].join(\"\\n\");\n\t}\n\tconst synthesizedCfg = {\n\t\ttype: \"imperative-read\" as const,\n\t\tinvokerShape: \"legacy\" as const,\n\t\tmcp: { toolName: cfg.mcp?.toolName },\n\t\tconfigJsonSchema: cfg.configJsonSchema,\n\t};\n\treturn [\n\t\t`import { ${cfg.factoryName} } from ${JSON.stringify(cfg.factoryModule)};`,\n\t\t`const __cfg_${name} = ${JSON.stringify(synthesizedCfg)};`,\n\t\t`const __imperativeAdapter_${name} = createReadAdapter(${JSON.stringify(name)}, __cfg_${name});`,\n\t\t`export default ${cfg.factoryName}(__imperativeAdapter_${name});`,\n\t].join(\"\\n\");\n}\n","/**\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\";\n\n/**\n * Splits the brace-content of a named-import statement into its individual\n * specifiers, surfacing both the original (pre-`as`) name and the full\n * `<original> as <local>` form. Used by the lds plugin's transform hook to\n * decide which names to rewrite to the virtual module.\n */\nexport function parseImportSpecifiers(bracesContent: string): { original: string; full: string }[] {\n\treturn bracesContent\n\t\t.split(\",\")\n\t\t.map((s) => s.trim())\n\t\t.filter(Boolean)\n\t\t.map((entry) => {\n\t\t\tconst asIdx = entry.indexOf(\" as \");\n\t\t\tconst original = asIdx !== -1 ? entry.slice(0, asIdx).trim() : entry.trim();\n\t\t\treturn { original, full: entry };\n\t\t});\n}\n\n/**\n * Removes top-level ES-module `export` keywords from the embedded runtime\n * source so its declarations survive as private bindings inside the virtual\n * module. Handles two shapes:\n * 1. Per-declaration: `export function foo …` / `export async function foo`\n * → the `export ` prefix is dropped.\n * 2. Trailing re-export clause: `export { foo, bar };` → deleted entirely.\n * Inner occurrences (inside function bodies, comments, strings) are not\n * affected because the source is a flat module with exports only at column 0.\n *\n * Internal: only `adapterBaseSource` is on the public deep-import surface;\n * the strip itself is an implementation detail.\n */\nfunction stripTopLevelExports(source: string): string {\n\treturn source\n\t\t.replace(/^export\\s+(?=(?:async\\s+)?function\\s)/gm, \"\")\n\t\t.replace(/^export\\s*\\{[^}]*};?\\s*$/gm, \"\");\n}\n\n// the source of the adapter base module — reused across virtual modules so\n// each generated specifier emits the factories once.\n//\n// Top-level exports from the runtime module are stripped so every factory and\n// `gql` becomes a private binding inside the virtual module. The load hook\n// then controls exactly which names are exported per specifier: adapter\n// entries from the registry, plus `gql` for graphql specifiers. Without this,\n// the built `runtime.js` (trailing `export { …, gql, createWireAdapter, … }`)\n// and the source `runtime.ts` (per-declaration `export function gql …`) both\n// produce a `SyntaxError: Duplicate export of 'gql'` when the load hook also\n// appends `export { gql };`. They also leak the factory names as exports on\n// every LDS virtual module, which isn't a public contract we want.\nexport const adapterBaseSource = stripTopLevelExports(\n\treadFileSync(join(dirname(fileURLToPath(import.meta.url)), \"runtime.js\"), \"utf-8\"),\n);\n","/**\n * Copyright (c) 2026, Salesforce, Inc.,\n * All rights reserved.\n * For full license text, see the LICENSE.txt file\n */\nimport { init, parse } from \"es-module-lexer\";\nimport MagicString from \"magic-string\";\nimport type { Plugin } from \"vite\";\nimport { isGraphqlSpecifier } from \"./adapters\";\nimport {\n\tGRAPHQL_TOOL,\n\ttype LdsRegistry,\n\ttype LdsRegistryEntry,\n\tOBJECT_INFO_SCHEMA,\n\tOBJECT_INFO_TOOL,\n\tRECORD_SCHEMA,\n\tRECORD_TOOL,\n} from \"./common-mcp-tooling\";\nimport { buildStateManagerCompositionBody, isStateManagerSpecifier } from \"./state-managers\";\nimport { adapterBaseSource, parseImportSpecifiers } from \"./util\";\nimport type { PassthroughRule } from \"../../types\";\n\n// Re-export the public type surface. Consumers (and `providers/index.ts`)\n// continue to import every registry-entry type from `./lds/index`.\nexport type {\n\tLdsMcpDispatch,\n\tLdsRegistry,\n\tLdsRegistryEntry,\n\tLdsRegistryEntryBase,\n\tLdsSchemaValidatedEntry,\n} from \"./common-mcp-tooling\";\nexport type {\n\tLdsGraphqlImperativeReadAdapterConfig,\n\tLdsGraphqlImperativeReadInvokerShape,\n\tLdsGraphqlMutationAdapterConfig,\n\tLdsGraphqlWireAdapterConfig,\n\tLdsImperativeMutationAdapterConfig,\n\tLdsImperativeReadAdapterConfig,\n\tLdsImperativeReadInvokerShape,\n\tLdsWireAdapterConfig,\n} from \"./adapters\";\nexport type { LdsStateManagerConfig } from \"./state-managers\";\n\n// prefix to write into transformed source code\nconst ADAPTER_PREFIX = \"sf-lds-adapter:\";\n// prefix used to ID the adapter when loading the virtual module\nconst ADAPTER_ID_PREFIX = \"\\0\" + ADAPTER_PREFIX;\n\n/**\n * Default registry.\n * Maps LDS module specifiers to MCP tool-backed implementations. Entries can be\n * wire adapters (`type: 'wire'`), imperative mutations (`type: 'imperative-mutation'`),\n * imperative reads (`type: 'imperative-read'` + `invokerShape`), GraphQL variants,\n * or state managers. Add entries here to support additional lightning/* exports.\n */\nconst DEFAULT_REGISTRY: LdsRegistry = {\n\t\"lightning/uiRecordApi\": {\n\t\tgetRecord: {\n\t\t\ttype: \"wire\",\n\t\t\tmcp: { toolName: RECORD_TOOL },\n\t\t\tconfigJsonSchema: RECORD_SCHEMA,\n\t\t},\n\t\tcreateRecord: {\n\t\t\ttype: \"imperative-mutation\",\n\t\t\tmcp: { toolName: \"createRecordMcpTool\" },\n\t\t\tconfigJsonSchema: {\n\t\t\t\ttype: \"object\",\n\t\t\t\tproperties: {\n\t\t\t\t\tapiName: { type: \"string\" },\n\t\t\t\t\tfields: {\n\t\t\t\t\t\ttype: \"object\",\n\t\t\t\t\t\tproperties: {},\n\t\t\t\t\t\trequired: [],\n\t\t\t\t\t\tadditionalProperties: true,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\trequired: [\"apiName\", \"fields\"],\n\t\t\t\tadditionalProperties: false,\n\t\t\t},\n\t\t},\n\t\tupdateRecord: {\n\t\t\ttype: \"imperative-mutation\",\n\t\t\tmcp: { toolName: \"updateRecordMcpTool\" },\n\t\t\tconfigJsonSchema: {\n\t\t\t\ttype: \"object\",\n\t\t\t\tproperties: {\n\t\t\t\t\trecordId: { type: \"string\" },\n\t\t\t\t\tfields: {\n\t\t\t\t\t\ttype: \"object\",\n\t\t\t\t\t\tproperties: {},\n\t\t\t\t\t\trequired: [],\n\t\t\t\t\t\tadditionalProperties: true,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\trequired: [\"recordId\", \"fields\"],\n\t\t\t\tadditionalProperties: false,\n\t\t\t},\n\t\t},\n\t},\n\t\"lightning/uiObjectInfoApi\": {\n\t\t// On-platform this is a `{ invoke, subscribe }` callback surface\n\t\t// emitting `{ data, error }`. The legacy invoker shape preserves that\n\t\t// contract verbatim, so ported consumers keep their call sites.\n\t\tgetObjectInfo_imperative: {\n\t\t\ttype: \"imperative-read\",\n\t\t\tinvokerShape: \"legacy\",\n\t\t\tmcp: { toolName: OBJECT_INFO_TOOL },\n\t\t\tconfigJsonSchema: OBJECT_INFO_SCHEMA,\n\t\t},\n\t},\n\t// `lightning/graphql` — on-platform exports `gql`, the `graphql` wire\n\t// adapter, and `executeMutation`. Only `graphql` and `executeMutation`\n\t// are registry entries; `gql` rides along automatically for any specifier\n\t// that has at least one graphql-typed entry (emitted by the load hook).\n\t\"lightning/graphql\": {\n\t\tgraphql: { type: \"graphql-wire\", mcp: { toolName: GRAPHQL_TOOL } },\n\t\texecuteMutation: { type: \"graphql-mutation\", mcp: { toolName: GRAPHQL_TOOL } },\n\t},\n\t// `lightning/stateManagerGraphQL` — externalized graphql state manager.\n\t// The load hook imports `createSmGraphQL` from the upstream\n\t// `@salesforce/lds-adapters-onestore-graphql/factory` barrel — a thin\n\t// per-state-manager wrapper around `createStateManager` that bakes in\n\t// the required (`['query']`) / optional (`['variables', 'operationName']`)\n\t// config keys, mirroring `createSmRecord` / `createSmObjectInfo`. The\n\t// same factory wraps the call site on-core via `bindings/bindings.ts`,\n\t// so off-core composition fidelity is preserved without on-core service\n\t// plumbing leaking into this side.\n\t//\n\t// Per §10.3 the registry only ever has `default` as its key — the\n\t// `createSmGraphQL` return value is itself the `default` export of\n\t// the virtual module.\n\t//\n\t// `configJsonSchema` is omitted: off-core graphql forgoes the on-core\n\t// `assertIsValid` / `resolveAndValidateGraphQLConfig` validation layer\n\t// (§4 Non-goal 9), and the load-hook graphql path doesn't read the\n\t// field anyway — malformed configs surface as MCP tool errors at\n\t// execute time instead.\n\t\"lightning/stateManagerGraphQL\": {\n\t\tdefault: {\n\t\t\ttype: \"state-manager\",\n\t\t\tfactoryModule: \"@salesforce/lds-adapters-onestore-graphql/factory\",\n\t\t\tfactoryName: \"createSmGraphQL\",\n\t\t\tmcp: { toolName: GRAPHQL_TOOL },\n\t\t},\n\t},\n\t// State-manager specifier for ObjectInfo (spec §8.3 / §10.3). The load hook\n\t// synthesizes a legacy-shape imperative-read adapter inline from\n\t// (mcp.toolName, configJsonSchema) and feeds it to the upstream\n\t// `createSmObjectInfo` factory. Reuses the shared `OBJECT_INFO_TOOL` /\n\t// `OBJECT_INFO_SCHEMA` so this entry stays in lock-step with the\n\t// `lightning/uiObjectInfoApi.getObjectInfo_imperative` entry above —\n\t// both back the same UIAPI ObjectInfo MCP tool.\n\t\"lightning/stateManagerObjectInfo\": {\n\t\tdefault: {\n\t\t\ttype: \"state-manager\",\n\t\t\tfactoryModule: \"@salesforce/state-managers-uiapi/factory\",\n\t\t\tfactoryName: \"createSmObjectInfo\",\n\t\t\tmcp: { toolName: OBJECT_INFO_TOOL },\n\t\t\tconfigJsonSchema: OBJECT_INFO_SCHEMA,\n\t\t},\n\t},\n\t// `lightning/stateManagerRecord` — UIAPI Record state-manager. Per spec\n\t// §10.3 the registry only ever has a single `default` key; the load hook\n\t// synthesizes a legacy-shape imperative-read adapter from\n\t// (mcp.toolName, configJsonSchema) and feeds it into the upstream\n\t// `createSmRecord` factory to produce the externalized state manager.\n\t// Reuses the shared `RECORD_TOOL` / `RECORD_SCHEMA` so the wire and\n\t// state-manager paths stay anchored to a single MCP-tool / config\n\t// contract.\n\t\"lightning/stateManagerRecord\": {\n\t\tdefault: {\n\t\t\ttype: \"state-manager\",\n\t\t\tfactoryModule: \"@salesforce/state-managers-uiapi/factory\",\n\t\t\tfactoryName: \"createSmRecord\",\n\t\t\tmcp: { toolName: RECORD_TOOL },\n\t\t\tconfigJsonSchema: RECORD_SCHEMA,\n\t\t},\n\t},\n};\n\n/** Maps an entry discriminator to the factory name emitted in the virtual module. */\nfunction factoryFor(type: LdsRegistryEntry[\"type\"]): string {\n\tswitch (type) {\n\t\tcase \"wire\":\n\t\t\treturn \"createWireAdapter\";\n\t\tcase \"imperative-mutation\":\n\t\t\treturn \"createMutationAdapter\";\n\t\tcase \"imperative-read\":\n\t\t\treturn \"createReadAdapter\";\n\t\tcase \"graphql-wire\":\n\t\t\treturn \"createGraphQLWireAdapter\";\n\t\tcase \"graphql-mutation\":\n\t\t\treturn \"createGraphQLMutationAdapter\";\n\t\tcase \"graphql-imperative-read\":\n\t\t\treturn \"createGraphQLImperativeReadAdapter\";\n\t\tcase \"state-manager\":\n\t\t\t// Load-hook directive name (consumed in W-05), not a runtime-import\n\t\t\t// factory: the load hook synthesizes an adapter inline and calls\n\t\t\t// the upstream factoryModule/factoryName to compose the state manager.\n\t\t\treturn \"createStateManagerComposition\";\n\t}\n}\n\n/**\n * Deep-merges user overrides onto the default registry: every specifier from\n * both sides is preserved, and per-specifier entries are merged so a consumer\n * can override `getRecord` without losing `createRecord`, or register a new\n * entry on `lightning/graphql` without losing `graphql` / `executeMutation`.\n * Pass an empty object to get just the defaults. To opt out of a default\n * entry, pass the same specifier with a different entry of the same key.\n */\nfunction mergeWithDefaults(overrides: LdsRegistry): LdsRegistry {\n\tconst merged: LdsRegistry = { ...DEFAULT_REGISTRY };\n\tfor (const [specifier, entries] of Object.entries(overrides)) {\n\t\tmerged[specifier] = { ...(DEFAULT_REGISTRY[specifier] ?? {}), ...entries };\n\t}\n\treturn merged;\n}\n\n/**\n * LDS provider — rewrites registered `lightning/*` imports (e.g.\n * `lightning/uiRecordApi`) to MCP-tool-backed virtual modules. Unregistered\n * exports pass through to the normal `lightning/*` resolution.\n *\n * Three Vite hooks do the work:\n *\n * - **`transform`** — parses each `.js` / `.ts` file with `es-module-lexer`,\n * finds named imports from registered specifiers, and rewrites them to pull\n * registered names from `sf-lds-adapter:<specifier>` while leaving\n * unregistered names pointing at the original specifier.\n *\n * - **`resolveId`** — maps `sf-lds-adapter:<specifier>` to a `\\0`-prefixed\n * virtual module ID, preventing Rollup from attempting a filesystem lookup.\n *\n * - **`load`** — generates the virtual module, emitting an MCP-backed\n * `createWireAdapter(...)` class for every `type: 'wire'` entry,\n * `createMutationAdapter(...)` for every `type: 'imperative-mutation'` entry,\n * and `createReadAdapter(...)` for every `type: 'imperative-read'` entry.\n *\n * Only specifiers present in the `adapters` registry are intercepted; imports from\n * unregistered specifiers pass through unchanged.\n */\nexport function lds(overrides: LdsRegistry = {}): Plugin & { passthroughRules: PassthroughRule[] } {\n\tconst adapters = mergeWithDefaults(overrides);\n\t// Graphql specifiers are owned whole by the virtual module — every export\n\t// (adapters + `gql`) lives there, so the transform hook should not split\n\t// their imports. Non-graphql specifiers still go through transform so\n\t// unregistered names pass through to the real `lightning/*` module.\n\tconst graphqlSpecifiers = new Set<string>(\n\t\tObject.entries(adapters)\n\t\t\t.filter(([, moduleAdapters]) => isGraphqlSpecifier(moduleAdapters))\n\t\t\t.map(([specifier]) => specifier),\n\t);\n\t// State-manager specifiers (`lightning/stateManager*`) are also owned\n\t// whole by the virtual module: their load-hook body emits `export default\n\t// <factory>(...)` per §10.4, so the public consumer surface is a default\n\t// import. The transform hook only rewrites brace-style named imports, so\n\t// state-manager specifiers are excluded from `transformSpecifiers` and\n\t// claimed in `resolveId` directly — same pattern as graphql specifiers.\n\tconst stateManagerSpecifiers = new Set<string>(\n\t\tObject.entries(adapters)\n\t\t\t.filter(([, moduleAdapters]) => isStateManagerSpecifier(moduleAdapters))\n\t\t\t.map(([specifier]) => specifier),\n\t);\n\tconst transformSpecifiers = Object.keys(adapters).filter(\n\t\t(s) => !graphqlSpecifiers.has(s) && !stateManagerSpecifiers.has(s),\n\t);\n\tconst specifierSnippets = transformSpecifiers.flatMap((s) => [`'${s}'`, `\"${s}\"`]);\n\n\t// State-manager `factoryModule` specifiers (e.g.\n\t// `@salesforce/state-managers-uiapi/factory`) are imported from inside the\n\t// emitted virtual module and must reach their real npm package — not the\n\t// scoped-providers fallback. The fallback would otherwise claim them via\n\t// any broad `@salesforce/` interceptPrefix derived from co-installed\n\t// providers (i18n / label / gate). Surface them as passthroughRules so the\n\t// main plugin can hand them to scopedProviders, which short-circuits when\n\t// the importer is one of our `sf-lds-adapter:` virtual modules.\n\tconst factoryModuleSpecifiers = new Set<string>();\n\tfor (const moduleAdapters of Object.values(adapters)) {\n\t\tfor (const entry of Object.values(moduleAdapters)) {\n\t\t\tif (entry.type === \"state-manager\") {\n\t\t\t\tfactoryModuleSpecifiers.add(entry.factoryModule);\n\t\t\t}\n\t\t}\n\t}\n\tconst passthroughRules: PassthroughRule[] = [...factoryModuleSpecifiers].map((specifier) => ({\n\t\tspecifierPrefix: specifier,\n\t\timporterPattern: ADAPTER_PREFIX,\n\t}));\n\n\tconst plugin: Plugin = {\n\t\tname: \"vite-plugin-lds\",\n\t\tenforce: \"pre\",\n\n\t\tasync transform(code, id) {\n\t\t\tconst cleanId = id.split(\"?\")[0] ?? id;\n\t\t\tif (!cleanId.endsWith(\".js\") && !cleanId.endsWith(\".ts\")) return null;\n\t\t\tif (cleanId.includes(\"/node_modules/\")) return null;\n\t\t\tif (!specifierSnippets.some((snippet) => code.includes(snippet))) return null;\n\n\t\t\tawait init;\n\n\t\t\tlet imports: ReturnType<typeof parse>[0];\n\t\t\ttry {\n\t\t\t\t[imports] = parse(code);\n\t\t\t} catch {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tconst relevant = imports.filter(\n\t\t\t\t(imp) =>\n\t\t\t\t\timp.d === -1 && imp.n !== undefined && imp.n in adapters && !graphqlSpecifiers.has(imp.n),\n\t\t\t);\n\t\t\tif (relevant.length === 0) return null;\n\n\t\t\tconst s = new MagicString(code);\n\t\t\tlet changed = false;\n\n\t\t\tfor (const imp of relevant) {\n\t\t\t\tconst { ss: start, se: end, n: specifier } = imp;\n\t\t\t\tconst statement = code.slice(start, end);\n\n\t\t\t\tconst openBrace = statement.indexOf(\"{\");\n\t\t\t\tconst closeBrace = statement.indexOf(\"}\");\n\t\t\t\tif (openBrace === -1 || closeBrace === -1) continue;\n\n\t\t\t\tconst bracesContent = statement.slice(openBrace + 1, closeBrace);\n\t\t\t\tconst moduleAdapters = adapters[specifier!]!;\n\t\t\t\tconst parsedImport = parseImportSpecifiers(bracesContent);\n\t\t\t\tconst registered = parsedImport.filter((p) => p.original in moduleAdapters);\n\t\t\t\tconst unregistered = parsedImport.filter((p) => !(p.original in moduleAdapters));\n\n\t\t\t\tif (registered.length === 0) continue;\n\n\t\t\t\tconst parts: string[] = [\n\t\t\t\t\t`import { ${registered.map((p) => p.full).join(\", \")} } from '${ADAPTER_PREFIX}${specifier}';`,\n\t\t\t\t];\n\n\t\t\t\tif (unregistered.length > 0) {\n\t\t\t\t\tparts.push(\n\t\t\t\t\t\t`import { ${unregistered.map((p) => p.full).join(\", \")} } from '${specifier}';`,\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\ts.overwrite(start, end, parts.join(\"\\n\"));\n\t\t\t\tchanged = true;\n\t\t\t}\n\n\t\t\tif (!changed) return null;\n\t\t\treturn { code: s.toString(), map: s.generateMap({ hires: true }) };\n\t\t},\n\n\t\tresolveId(id) {\n\t\t\t// Graphql + state-manager specifiers are intercepted raw — no\n\t\t\t// transform hook split — and mapped into the same\n\t\t\t// `\\0sf-lds-adapter:` virtual namespace so the load hook emits one\n\t\t\t// module per specifier. State-manager modules expose `default` as\n\t\t\t// their only public export (§10.4), so default imports of\n\t\t\t// `lightning/stateManager*` need this interception to reach the\n\t\t\t// virtual module body.\n\t\t\tif (graphqlSpecifiers.has(id) || stateManagerSpecifiers.has(id)) {\n\t\t\t\treturn ADAPTER_ID_PREFIX + id;\n\t\t\t}\n\t\t\tif (id.startsWith(ADAPTER_PREFIX)) return ADAPTER_ID_PREFIX + id.slice(ADAPTER_PREFIX.length);\n\t\t\treturn null;\n\t\t},\n\n\t\tload(id) {\n\t\t\tif (!id.startsWith(ADAPTER_ID_PREFIX)) return null;\n\n\t\t\tconst specifier = id.slice(ADAPTER_ID_PREFIX.length);\n\t\t\tconst moduleAdapters = adapters[specifier];\n\t\t\tif (!moduleAdapters) return null;\n\n\t\t\t// create lines of code used to create MCP tool based adapters\n\t\t\tconst lines: string[] = [adapterBaseSource];\n\t\t\tfor (const [name, entry] of Object.entries(moduleAdapters)) {\n\t\t\t\tif (entry.type === \"state-manager\") {\n\t\t\t\t\t// State-manager entries do not call a runtime factory like\n\t\t\t\t\t// the other types. Per spec §8.4 / §10.4, the load hook\n\t\t\t\t\t// emits a small composition block that synthesizes a\n\t\t\t\t\t// legacy-shape imperative adapter inline and feeds it into\n\t\t\t\t\t// the upstream `<factoryName>` from `<factoryModule>`.\n\t\t\t\t\tlines.push(buildStateManagerCompositionBody(name, entry, specifier));\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tconst { type, ...cfg } = entry;\n\t\t\t\tlines.push(\n\t\t\t\t\t`export const ${name} = ${factoryFor(type)}(${JSON.stringify(name)}, ${JSON.stringify(cfg)});`,\n\t\t\t\t);\n\t\t\t}\n\t\t\t// `gql` rides along with any specifier that declares a graphql\n\t\t\t// adapter, so `import { gql } from 'lightning/graphql'` (or any\n\t\t\t// aliased form) keeps resolving even when no adapters are\n\t\t\t// imported alongside it. The binding itself is a private function\n\t\t\t// inside `adapterBaseSource` after `stripTopLevelExports`.\n\t\t\tif (graphqlSpecifiers.has(specifier)) {\n\t\t\t\tlines.push(\"export { gql };\");\n\t\t\t}\n\t\t\treturn lines.join(\"\\n\");\n\t\t},\n\t};\n\treturn Object.assign(plugin, { passthroughRules });\n}\n"],"names":[],"mappings":";;;;;AAkGO,SAAS,mBAAmB,gBAA2D;AAC7F,SAAO,OAAO,OAAO,cAAc,EAAE;AAAA,IACpC,CAAC,UACA,MAAM,SAAS,kBACf,MAAM,SAAS,sBACf,MAAM,SAAS;AAAA,EAAA;AAElB;AClCO,MAAM,cAAc;AACpB,MAAM,gBAA4B;AAAA,EACxC,MAAM;AAAA,EACN,YAAY;AAAA,IACX,UAAU,EAAE,MAAM,SAAA;AAAA,IAClB,aAAa;AAAA,MACZ,OAAO,CAAC,EAAE,MAAM,SAAS,OAAO,EAAE,MAAM,S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escriptor, buildQueryImperativeBindingsServiceDescriptor, buildSubscribableImperativeBindingsServiceDescriptor, buildLegacyImperativeBindingsServiceDescriptor } from "@conduit-client/service-bindings-imperative/v1";
2
2
  import { buildLWCWireBindingsServiceDescriptor } from "@conduit-client/service-bindings-lwc/v1";
3
- import { err, ok, toError, buildSubscribableResult } from "@conduit-client/utils";
3
+ import { ok, UserVisibleError, err, buildSubscribableResult, toError } from "@conduit-client/utils";
4
4
  import { getChatSDK } from "@salesforce/platform-sdk";
5
5
  function normalizeMcpResponse(raw) {
6
6
  if (raw && typeof raw === "object" && "structuredContent" in raw) {
@@ -110,6 +110,30 @@ class McpToolSubscribableCommand {
110
110
  return buildSubscribableResult(result, subscribe, refresh);
111
111
  }
112
112
  }
113
+ function createGraphqlStateManagerCommand(name, cfg) {
114
+ const toolName = resolveMcpToolName(name, cfg);
115
+ return (config) => ({
116
+ async execute() {
117
+ const base = new McpToolSubscribableCommand(name, toolName, {
118
+ query: config.query,
119
+ variables: config.variables ?? {},
120
+ ...config.operationName !== void 0 && { operationName: config.operationName }
121
+ });
122
+ const subscribable = await base.execute();
123
+ if (subscribable.isOk()) {
124
+ return ok(subscribable.value);
125
+ }
126
+ const innerError = subscribable.error.failure;
127
+ const message = innerError.message;
128
+ const userVisible = new UserVisibleError({
129
+ data: void 0,
130
+ errors: [{ message }]
131
+ });
132
+ userVisible.message = message;
133
+ return err({ ...subscribable.error, failure: userVisible });
134
+ }
135
+ });
136
+ }
113
137
  const defaultImperativeService = buildDefaultImperativeBindingsServiceDescriptor().service;
114
138
  const queryImperativeService = buildQueryImperativeBindingsServiceDescriptor().service;
115
139
  const subscribableImperativeService = buildSubscribableImperativeBindingsServiceDescriptor().service;
@@ -189,12 +213,16 @@ function gql(strings, ...values) {
189
213
  return result.trim();
190
214
  }
191
215
  async function runGraphqlQuery(adapterName, toolName, config) {
192
- const { query, variables } = config;
216
+ const { query, variables, operationName } = config;
193
217
  if (!query) return { data: void 0, errors: void 0 };
194
218
  const callTool = await getCallTool(adapterName);
195
219
  const raw = await callTool({
196
220
  toolName,
197
- params: { query, variables: variables ?? {} }
221
+ params: {
222
+ query,
223
+ variables: variables ?? {},
224
+ ...operationName !== void 0 && { operationName }
225
+ }
198
226
  });
199
227
  return normalizeMcpResponse(raw) ?? {};
200
228
  }
@@ -235,7 +263,7 @@ function createGraphQLWireAdapter(name, cfg) {
235
263
  return this._fetch();
236
264
  }
237
265
  async _fetch() {
238
- this._emit(await runGraphqlQuerySafe(name, toolName, this._config ?? {}));
266
+ this._emit(await runGraphqlQuerySafe(name, toolName, this._config ?? { query: "" }));
239
267
  }
240
268
  _emit({ data, errors }) {
241
269
  this._dataCallback({
@@ -320,6 +348,7 @@ export {
320
348
  createGraphQLImperativeReadAdapter,
321
349
  createGraphQLMutationAdapter,
322
350
  createGraphQLWireAdapter,
351
+ createGraphqlStateManagerCommand,
323
352
  createMutationAdapter,
324
353
  createReadAdapter,
325
354
  createWireAdapter,