@salesforce/afv-skills 1.37.0 → 1.38.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.
Files changed (247) hide show
  1. package/package.json +1 -1
  2. package/skills/agentforce-generate/README.md +20 -3
  3. package/skills/agentforce-generate/SKILL.md +253 -440
  4. package/skills/agentforce-generate/assets/agent-spec-template.md +6 -2
  5. package/skills/agentforce-generate/assets/agents/order-service.agent +16 -12
  6. package/skills/agentforce-generate/assets/agents/production-faq.agent +4 -4
  7. package/skills/agentforce-generate/assets/agents/router-first.agent +5 -5
  8. package/skills/agentforce-generate/assets/agents/template-single-subagent.agent +4 -4
  9. package/skills/agentforce-generate/assets/agents/verification-gate.agent +8 -6
  10. package/skills/agentforce-generate/assets/agents/voice-knowledge-grounded.agent +9 -9
  11. package/skills/agentforce-generate/assets/agents/voice-service-agent.agent +7 -7
  12. package/skills/agentforce-generate/assets/patterns/README.md +3 -3
  13. package/skills/agentforce-generate/assets/patterns/action-callbacks.agent +5 -5
  14. package/skills/agentforce-generate/assets/patterns/advanced-input-bindings.agent +6 -8
  15. package/skills/agentforce-generate/assets/patterns/bidirectional-routing.agent +11 -13
  16. package/skills/agentforce-generate/assets/patterns/critical-input-collection.agent +11 -16
  17. package/skills/agentforce-generate/assets/patterns/lifecycle-events.agent +2 -3
  18. package/skills/agentforce-generate/assets/patterns/llm-controlled-actions.agent +6 -7
  19. package/skills/agentforce-generate/assets/patterns/open-gate-routing.agent +3 -3
  20. package/skills/agentforce-generate/assets/patterns/prompt-template-action.agent +14 -19
  21. package/skills/agentforce-generate/assets/patterns/system-instruction-overrides.agent +11 -20
  22. package/skills/agentforce-generate/references/actions-reference.md +2 -2
  23. package/skills/agentforce-generate/references/agent-audit-and-repair.md +135 -0
  24. package/skills/agentforce-generate/references/agent-audit-candidate-verification.md +160 -0
  25. package/skills/agentforce-generate/references/agent-audit-diagnostic-catalog.md +156 -0
  26. package/skills/agentforce-generate/references/agent-audit-diagnostics-actions-state.md +176 -0
  27. package/skills/agentforce-generate/references/agent-audit-diagnostics-architecture-evaluation.md +68 -0
  28. package/skills/agentforce-generate/references/agent-audit-diagnostics-instructions-routing.md +283 -0
  29. package/skills/agentforce-generate/references/agent-audit-evaluation-loop.md +191 -0
  30. package/skills/agentforce-generate/references/agent-audit-repair-report.md +143 -0
  31. package/skills/agentforce-generate/references/agent-audit-scope-path-review.md +180 -0
  32. package/skills/agentforce-generate/references/agent-design-and-spec-creation.md +105 -59
  33. package/skills/agentforce-generate/references/agent-script-core-language.md +144 -61
  34. package/skills/agentforce-generate/references/agent-subagent-map-diagrams.md +33 -23
  35. package/skills/agentforce-generate/references/agent-validation-and-debugging.md +37 -11
  36. package/skills/agentforce-generate/references/agentscript-toolchain.md +112 -0
  37. package/skills/agentforce-generate/references/architecture-patterns.md +81 -18
  38. package/skills/agentforce-generate/references/common-control-flow-pitfalls.md +255 -0
  39. package/skills/agentforce-generate/references/control-flow-actions-sequencing.md +198 -0
  40. package/skills/agentforce-generate/references/control-flow-lifecycle-side-effects.md +87 -0
  41. package/skills/agentforce-generate/references/examples.md +22 -22
  42. package/skills/agentforce-generate/references/instruction-resolution.md +123 -83
  43. package/skills/agentforce-generate/references/known-issues.md +1 -2
  44. package/skills/agentforce-generate/references/optimization-pattern-1-data-flow.md +4 -0
  45. package/skills/agentforce-generate/references/optimization-pattern-2-deterministic-logic.md +33 -0
  46. package/skills/agentforce-generate/references/optimization-pattern-3-reference-syntax.md +32 -3
  47. package/skills/agentforce-generate/references/optimization-pattern-4-escalation.md +2 -2
  48. package/skills/agentforce-generate/references/patterns-by-requirement.md +3 -1
  49. package/skills/agentforce-generate/references/posture-and-determinism.md +103 -22
  50. package/skills/agentforce-generate/references/reference-map.md +19 -3
  51. package/skills/agentforce-generate/references/scoring-rubric.md +1 -1
  52. package/skills/agentforce-generate/references/voice-latency-heuristics.md +4 -0
  53. package/skills/agentforce-generate/references/voice-modality-reference.md +4 -4
  54. package/skills/agentforce-generate/references/zen-of-agentscript.md +139 -23
  55. package/skills/agentforce-generate/scripts/agentscript-sdk-loader.mjs +133 -0
  56. package/skills/agentforce-generate/scripts/index-agent.mjs +141 -0
  57. package/skills/agentforce-generate/scripts/setup-agentscript-sdk.mjs +337 -0
  58. package/skills/automation-sandbox-post-copy-config-generate/SKILL.md +1 -1
  59. package/skills/automation-sandbox-post-copy-configure/SKILL.md +433 -0
  60. package/skills/automation-sandbox-post-copy-configure/assets/api_request_templates.json +89 -0
  61. package/skills/automation-sandbox-post-copy-configure/examples/sample_config_input.json +40 -0
  62. package/skills/automation-sandbox-post-copy-configure/examples/sample_execution_summary.md +79 -0
  63. package/skills/automation-sandbox-post-copy-configure/references/api_endpoints.md +273 -0
  64. package/skills/automation-sandbox-post-copy-configure/references/authentication.md +94 -0
  65. package/skills/automation-sandbox-post-copy-configure/references/execution_phasing.md +93 -0
  66. package/skills/automation-sandbox-post-copy-configure/references/rules_gotchas.md +35 -0
  67. package/skills/automation-sandbox-post-copy-configure/scripts/classify-patch-result.mjs +88 -0
  68. package/skills/automation-sandbox-post-copy-configure/scripts/map-metadata-key.mjs +98 -0
  69. package/skills/automation-sandbox-post-copy-configure/scripts/plan-phases.mjs +98 -0
  70. package/skills/automation-sandbox-post-copy-configure/scripts/resolve-target-org.mjs +56 -0
  71. package/skills/design-systems-slds-validate/SKILL.md +14 -13
  72. package/skills/dx-code-analyzer-custom-rule-create/examples/xpath-examples.md +1 -1
  73. package/skills/dx-code-analyzer-custom-rule-create/references/xpath-patterns-security.md +1 -1
  74. package/skills/dx-org-devhub-configure/SKILL.md +268 -0
  75. package/skills/dx-org-devhub-configure/examples/status-output.md +39 -0
  76. package/skills/dx-org-devhub-configure/scripts/devhub.sh +650 -0
  77. package/skills/dx-org-devhub-configure/scripts/test-devhub.sh +116 -0
  78. package/skills/dx-org-manage/SKILL.md +135 -42
  79. package/skills/dx-org-manage/assets/derive-alias.sh +95 -0
  80. package/skills/dx-org-manage/assets/scratch-def.seed.json +6 -0
  81. package/skills/dx-org-manage/examples/README.md +1 -1
  82. package/skills/dx-org-manage/examples/scratch-orgs/delete_output.json +8 -0
  83. package/skills/dx-org-manage/examples/scratch-orgs/display_output.json +23 -0
  84. package/skills/dx-org-manage/examples/scratch-orgs/list_output.json +58 -0
  85. package/skills/dx-org-manage/examples/scratch-orgs/resume_output.json +38 -0
  86. package/skills/dx-org-manage/examples/scratch-orgs/success_definition_file.json +1 -1
  87. package/skills/dx-org-manage/examples/scratch-orgs/success_edition.json +1 -1
  88. package/skills/dx-org-manage/examples/scratch-orgs/success_shape.json +41 -0
  89. package/skills/dx-org-manage/examples/scratch-orgs/success_snapshot.json +1 -1
  90. package/skills/dx-org-manage/examples/snapshots/error_output.json +3 -3
  91. package/skills/dx-org-manage/references/creating-scratch-org.md +2 -2
  92. package/skills/dx-org-manage/references/creating-snapshot.md +1 -2
  93. package/skills/dx-org-manage/references/definition_file_options.md +24 -0
  94. package/skills/dx-org-manage/references/edition_types.md +10 -8
  95. package/skills/dx-org-manage/references/opening-org.md +11 -12
  96. package/skills/dx-org-manage/references/scratch-org-create.md +303 -0
  97. package/skills/dx-org-manage/references/scratch-org-operations.md +135 -0
  98. package/skills/experience-aura-lwc-migrate/SKILL.md +120 -0
  99. package/skills/experience-aura-lwc-migrate/references/aura-api-expert.md +170 -0
  100. package/skills/experience-aura-lwc-migrate/references/aura-data-expert.md +172 -0
  101. package/skills/experience-aura-lwc-migrate/references/aura-migration-guidelines.md +299 -0
  102. package/skills/experience-aura-lwc-migrate/references/aura-prd-framework.md +79 -0
  103. package/skills/experience-aura-lwc-migrate/references/aura-redundant-code-expert.md +24 -0
  104. package/skills/experience-aura-lwc-migrate/references/aura-reference-expert.md +140 -0
  105. package/skills/experience-aura-lwc-migrate/references/aura-resolver-expert.md +115 -0
  106. package/skills/experience-aura-lwc-migrate/references/aura-slots-expert.md +67 -0
  107. package/skills/experience-aura-lwc-migrate/references/aura-style-expert.md +62 -0
  108. package/skills/experience-aura-lwc-migrate/references/aura-to-lwc-completeness-checklist.md +188 -0
  109. package/skills/experience-aura-lwc-migrate/references/aura-values-expert.md +67 -0
  110. package/skills/experience-content-media-search/SKILL.md +17 -12
  111. package/skills/experience-content-media-stock-image-search/SKILL.md +192 -0
  112. package/skills/experience-content-media-stock-image-search/scripts/download-stock-image.py +102 -0
  113. package/skills/experience-lds-best-practices-apply/SKILL.md +245 -0
  114. package/skills/experience-lds-best-practices-apply/references/adapter-apis.md +1640 -0
  115. package/skills/experience-lds-best-practices-apply/references/lds-data-consistency.md +126 -0
  116. package/skills/experience-lds-best-practices-apply/references/lds-expert.md +429 -0
  117. package/skills/experience-lds-best-practices-apply/references/lds-referential-integrity.md +322 -0
  118. package/skills/experience-lds-best-practices-apply/references/wire-adapter-types.md +1511 -0
  119. package/skills/experience-lds-graphql-generate/SKILL.md +222 -0
  120. package/skills/experience-lds-graphql-generate/references/generation-guide.md +236 -0
  121. package/skills/experience-lds-graphql-generate/references/generation-mutation.md +277 -0
  122. package/skills/experience-lds-graphql-generate/references/generation-query.md +237 -0
  123. package/skills/experience-lds-graphql-generate/scripts/fetch-lds-graphql-schema.sh +230 -0
  124. package/skills/experience-lds-graphql-generate/scripts/test-lds-graphql-query.sh +128 -0
  125. package/skills/experience-lwc-accessibility-validate/SKILL.md +112 -0
  126. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-1-1-1-non-text-content.md +88 -0
  127. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-1-3-1-i-lists.md +52 -0
  128. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-1-3-1-ii-tables.md +106 -0
  129. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-1-3-1-iii-form-labels.md +78 -0
  130. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-1-3-1-iv-regions.md +26 -0
  131. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-1-3-1-v-groups.md +66 -0
  132. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-1-3-5-identify-input.md +70 -0
  133. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-1-4-3-contrast.md +115 -0
  134. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-2-1-1-keyboard.md +47 -0
  135. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-2-4-4-link-purpose.md +39 -0
  136. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-2-4-6-headings-labels.md +50 -0
  137. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-2-5-1-pointer-gestures.md +54 -0
  138. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-2-5-2-pointer-cancellation.md +49 -0
  139. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-2-5-3-label-in-name.md +77 -0
  140. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-2-5-7-dragging-movement.md +45 -0
  141. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-3-2-1-on-focus.md +55 -0
  142. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-3-2-2-on-input.md +51 -0
  143. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-3-3-1-error-identification.md +84 -0
  144. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-3-3-2-labels-instructions.md +50 -0
  145. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-3-3-3-error-suggestion.md +64 -0
  146. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-4-1-2-i-name.md +105 -0
  147. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-4-1-2-ii-role.md +99 -0
  148. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-4-1-2-iii-value.md +97 -0
  149. package/skills/experience-lwc-accessibility-validate/references/vision/sc-1-1-1-non-text-content.md +83 -0
  150. package/skills/experience-lwc-accessibility-validate/references/vision/sc-1-4-1-use-of-color.md +62 -0
  151. package/skills/experience-lwc-accessibility-validate/references/vision/sc-1-4-10-resize-reflow.md +18 -0
  152. package/skills/experience-lwc-accessibility-validate/references/vision/sc-1-4-11-non-text-contrast.md +43 -0
  153. package/skills/experience-lwc-accessibility-validate/references/vision/sc-1-4-3-contrast.md +25 -0
  154. package/skills/experience-lwc-accessibility-validate/scripts/contrast-ratio.py +153 -0
  155. package/skills/experience-lwc-design-generate/SKILL.md +261 -0
  156. package/skills/experience-lwc-design-generate/references/figma-to-prd-blueprint.md +66 -0
  157. package/skills/experience-lwc-design-generate/references/prd-analysis-template.md +17 -0
  158. package/skills/experience-lwc-design-generate/scripts/check-component-name.sh +75 -0
  159. package/skills/experience-lwc-design-generate/scripts/detect-project-tools.sh +97 -0
  160. package/skills/experience-lwc-runtime-observe/SKILL.md +244 -0
  161. package/skills/experience-lwc-runtime-observe/examples/component-preview-and-dom.md +41 -0
  162. package/skills/experience-lwc-runtime-observe/scripts/extract-dom.sh +79 -0
  163. package/skills/experience-lwc-runtime-observe/scripts/open-frontdoor.sh +46 -0
  164. package/skills/experience-lwc-runtime-observe/scripts/verify-toolchain.sh +48 -0
  165. package/skills/experience-lwc-security-validate/SKILL.md +151 -0
  166. package/skills/experience-lwc-security-validate/examples/review-report.md +6 -0
  167. package/skills/experience-lwc-security-validate/examples/score-report.sarif.json +32 -0
  168. package/skills/experience-lwc-security-validate/references/lws-security-expert.md +986 -0
  169. package/skills/experience-lwc-security-validate/references/security-analysis.md +611 -0
  170. package/skills/experience-lwc-security-validate/scripts/check-lwc-import.sh +166 -0
  171. package/skills/experience-lwc-security-validate/scripts/validate-sarif.sh +131 -0
  172. package/skills/experience-ui-bundle-2gp-deploy/SKILL.md +454 -0
  173. package/skills/experience-ui-bundle-2gp-deploy/assets/CustomApplication.app-meta.xml +12 -0
  174. package/skills/experience-ui-bundle-2gp-deploy/assets/PermissionSet.permissionset-meta.xml +9 -0
  175. package/skills/experience-ui-bundle-2gp-deploy/scripts/find-bundle-package-dir.sh +53 -0
  176. package/skills/experience-ui-bundle-agentforce-client-generate/SKILL.md +104 -26
  177. package/skills/experience-ui-bundle-agentforce-client-generate/references/constraints.md +35 -24
  178. package/skills/experience-ui-bundle-agentforce-client-generate/references/examples.md +92 -1
  179. package/skills/experience-ui-bundle-agentforce-client-generate/references/style-tokens.md +2 -0
  180. package/skills/experience-ui-bundle-agentforce-client-generate/references/troubleshooting.md +14 -1
  181. package/skills/experience-ui-bundle-agentforce-client-generate/scripts/detect-framework.sh +67 -0
  182. package/skills/experience-ui-bundle-deploy/SKILL.md +83 -14
  183. package/skills/experience-ui-bundle-deploy/assets/Communities.settings-meta.xml +19 -0
  184. package/skills/experience-ui-bundle-deploy/assets/org-setup.config.template.json +5 -0
  185. package/skills/experience-ui-bundle-deploy/assets/social-login-auth-providers.apex +158 -0
  186. package/skills/experience-ui-bundle-deploy/references/config-scaffold.md +13 -1
  187. package/skills/experience-ui-bundle-deploy/references/social-login.md +179 -0
  188. package/skills/experience-ui-bundle-frontend-generate/SKILL.md +14 -0
  189. package/skills/experience-ui-bundle-mfa-configure/SKILL.md +6 -5
  190. package/skills/experience-ui-bundle-mfa-configure/references/social-login.md +15 -7
  191. package/skills/experience-ui-bundle-salesforce-data-access/SKILL.md +41 -5
  192. package/skills/experience-ui-bundle-salesforce-data-access/references/caching.md +10 -22
  193. package/skills/experience-ui-bundle-salesforce-data-access/references/graphql-hand-authoring.md +4 -19
  194. package/skills/experience-ui-bundle-salesforce-data-access/references/migration.md +5 -0
  195. package/skills/experience-ui-bundle-salesforce-data-access/references/sdk-api.md +33 -150
  196. package/skills/mobile-platform-native-capabilities-integrate/references/nfc.md +35 -0
  197. package/skills/platform-apex-generate/SKILL.md +8 -7
  198. package/skills/platform-apex-test-generate/SKILL.md +3 -1
  199. package/skills/platform-apex-test-run/SKILL.md +9 -8
  200. package/skills/platform-lightning-type-widget-coordinate/SKILL.md +1 -1
  201. package/skills/platform-lightning-type-widget-coordinate/examples/existing-lightning-type-with-widget-prompt.md +1 -1
  202. package/skills/platform-lightning-type-widget-coordinate/examples/new-lightning-type-with-widget-prompt.md +1 -1
  203. package/skills/platform-lightning-type-widget-coordinate/references/validation-gates.md +3 -3
  204. package/skills/platform-mcp-tool-widget-coordinate/SKILL.md +43 -67
  205. package/skills/platform-mcp-tool-widget-coordinate/examples/action-name-source-prompt.md +1 -2
  206. package/skills/platform-mcp-tool-widget-coordinate/examples/apex-invocable-source-prompt.md +2 -3
  207. package/skills/platform-mcp-tool-widget-coordinate/examples/nested-object-list-source-prompt.md +163 -0
  208. package/skills/platform-mcp-tool-widget-coordinate/examples/nested-object-single-source-prompt.md +198 -0
  209. package/skills/platform-mcp-tool-widget-coordinate/examples/pasted-tool-output-prompt.md +0 -1
  210. package/skills/platform-mcp-tool-widget-coordinate/references/build-plan-format.md +17 -11
  211. package/skills/platform-mcp-tool-widget-coordinate/references/mcp-tool-output-discovery.md +48 -15
  212. package/skills/platform-mcp-tool-widget-coordinate/references/two-clt-modeling.md +73 -10
  213. package/skills/platform-mcp-tool-widget-coordinate/references/validation-gates.md +48 -8
  214. package/skills/platform-policy-rule-generate/SKILL.md +22 -12
  215. package/skills/platform-policy-rule-generate/references/deploy-errors.md +1 -1
  216. package/skills/platform-policy-rule-generate/references/policy-schema-full.md +8 -29
  217. package/skills/platform-policy-rule-generate/references/templates-advanced.md +1 -1
  218. package/skills/platform-sharing-owd-configure/SKILL.md +20 -8
  219. package/skills/platform-sharing-owd-configure/references/access_levels.md +14 -1
  220. package/skills/platform-sharing-rules-generate/SKILL.md +67 -35
  221. package/skills/platform-sharing-rules-generate/examples/create-cases.md +16 -17
  222. package/skills/platform-sharing-rules-generate/examples/delete-cases.md +34 -79
  223. package/skills/platform-sharing-rules-generate/examples/edit-cases.md +13 -26
  224. package/skills/platform-sharing-rules-generate/scripts/count-remaining-rules.sh +33 -0
  225. package/skills/platform-widget-generate/SKILL.md +3 -5
  226. package/skills/platform-widget-generate/examples/conditional.json +18 -13
  227. package/skills/platform-widget-generate/examples/list-with-foreach.json +2 -2
  228. package/skills/platform-widget-generate/examples/single-object.json +2 -2
  229. package/skills/platform-widget-generate/references/schema-from-lightning-type.md +27 -6
  230. package/skills/platform-widget-generate/references/widget-bundle-layout.md +4 -3
  231. package/skills/service-itsm-agentic-setup-cmdb-access-assign/SKILL.md +287 -0
  232. package/skills/service-itsm-agentic-setup-cmdb-access-assign/references/mcp-invocation.md +260 -0
  233. package/skills/service-itsm-agentic-setup-cmdb-bundle-deploy/SKILL.md +252 -0
  234. package/skills/service-itsm-agentic-setup-cmdb-bundle-deploy/references/mcp-invocation.md +204 -0
  235. package/skills/service-itsm-agentic-setup-cmdb-configure/SKILL.md +259 -0
  236. package/skills/service-itsm-agentic-setup-cmdb-configure/references/mcp-invocation.md +188 -0
  237. package/skills/service-itsm-agentic-setup-cmdb-coordinate/SKILL.md +197 -0
  238. package/skills/service-itsm-agentic-setup-cmdb-coordinate/examples/output-templates.md +77 -0
  239. package/skills/service-itsm-agentic-setup-cmdb-discovery-configure/SKILL.md +316 -0
  240. package/skills/service-itsm-agentic-setup-cmdb-discovery-configure/references/mcp-invocation.md +221 -0
  241. package/skills/service-itsm-incident-priority-configure/SKILL.md +168 -0
  242. package/skills/service-itsm-incident-priority-configure/examples/matrix-operations.md +200 -0
  243. package/skills/service-itsm-incident-priority-configure/examples/render-matrix.md +54 -0
  244. package/skills/service-itsm-incident-priority-configure/examples/seed-full-matrix.md +52 -0
  245. package/skills/service-itsm-incident-priority-configure/references/sf-cli-invocation.md +264 -0
  246. package/skills/platform-mcp-tool-widget-coordinate/examples/nested-object-source-prompt.md +0 -191
  247. package/skills/platform-policy-rule-generate/references/fixtures-index.md +0 -29
@@ -0,0 +1,277 @@
1
+ # GraphQL Mutation Query Generation
2
+
3
+ **Triggering conditions**
4
+
5
+ 1. Only after Steps 1–4 of [generation-guide.md](generation-guide.md) have completed successfully (introspection produced a `SUCCESS` status with no unknown entities or fields)
6
+ 2. Only if the query to generate is a mutation query
7
+
8
+ ## Your Role
9
+
10
+ You are a GraphQL expert and your role is to help generate Salesforce-compatible GraphQL mutation queries once the exploration phase has completed.
11
+
12
+ If the introspection workflow in [generation-guide.md](generation-guide.md) has not been executed yet, you **MUST** run it first, and then return to mutation query generation.
13
+
14
+ You will leverage the context provided by the requesting user as well as the validated introspection results from [generation-guide.md](generation-guide.md) to generate the queries, and then test them against a live org using the bundled `scripts/test-lds-graphql-query.sh` script.
15
+
16
+ ## Mutation Queries General Information
17
+
18
+ **IMPORTANT**:
19
+
20
+ 1. **Mutation Types**: The GraphQL engine supports `Create`, `Update` and `Delete` operations
21
+ 2. **Id Based Mutations**: `Update` and `Delete` operations operate on Id-based entity identification
22
+ 3. **Mutation Schema**: Defined in the [mutation query schema](#mutation-query-schema) section
23
+
24
+ ## Mutation Query Generation Workflow
25
+
26
+ Strictly follow the rules below when generating the GraphQL mutation query:
27
+
28
+ 1. **Input Fields Validation** - Validate that the set of fields validate [input field constraints](#mutation-queries-input-field-constraints)
29
+ 2. **Output Fields Validation** - Validate that the set of fields used in the select part of the query validate the [output fields constraints](#mutation-queries-output-field-constraints)
30
+ 3. **Type Consistency** - Make sure variables used as query arguments and their related fields share the same GraphQL type
31
+ 4. **Report Phase** - Use the [Mutation Query Report Template](#mutation-query-report-template) below to report on the previous validation phases
32
+ 5. **Input Arguments** - `input` is the default name for the argument, unless otherwise specified
33
+ 6. **Output Field** - For `Create` and `Update` operations, the output field is always named `Record`, and is of type EntityName
34
+ 7. **Mutations Chaining** - It is possible to chain mutations in a single query using the [Mutations Chaining](#mutations-chaining) instructions
35
+ 8. **Query Generation** - Use the [mutation query](#mutation-query-templates) template and adjust it based on the selected operation
36
+ 9. **Output Format** - Use the [standalone](#mutation-standalone-default-output-format---clean-code-only) or [LWC](#mutation-lwc-integration-only-when-requested-output-format) output format templates based on desired output
37
+ 10. **Report** - Always report, using the proper output format, before testing
38
+ 11. **Test the Query** - Use the [Generated Mutation Query Testing](#generated-mutation-query-testing) workflow to test the generated query
39
+
40
+ ## Mutation Query Schema
41
+
42
+ **Important**: In the schema fragments below, replace **EntityName** occurrences by the real entity name (i.e. Account, Case...).
43
+ **Important**: `Delete` operations all share the same generic `Record` entity name for both input and payload, only exposing the standard `Id` field.
44
+
45
+ ```graphql
46
+ input EntityNameCreateRepresentation {
47
+ # Subset of EntityName fields here
48
+ }
49
+ input EntityNameCreateInput { EntityName: EntityNameCreateRepresentation! }
50
+ type EntityNameCreatePayload { Record: EntityName! }
51
+
52
+ input EntityNameUpdateRepresentation {
53
+ # Subset of EntityName fields here
54
+ }
55
+ input EntityNameUpdateInput { Id: IdOrRef! EntityName: EntityNameUpdateRepresentation! }
56
+ type EntityNameUpdatePayload { Record: EntityName! }
57
+
58
+ input RecordDeleteInput { Id: IdOrRef! }
59
+ type RecordDeletePayload { Id: ID }
60
+
61
+ type UIAPIMutations {
62
+ EntityNameCreate(input: EntityNameCreateInput!): EntityNameCreatePayload
63
+ EntityNameDelete(input: RecordDeleteInput!): RecordDeletePayload
64
+ EntityNameUpdate(input: EntityNameUpdateInput!): EntityNameUpdatePayload
65
+ }
66
+ ```
67
+
68
+ ## Mutation Queries Input Field Constraints
69
+
70
+ 1. **`Create` Mutation Queries**:
71
+ 1. **MUST** include all required fields, unless they have `defaultedOnCreate` set to `true` and are not explicitly requested
72
+ 2. **MUST** only include `createable` fields
73
+ 3. Child relationships can't be set and **MUST** be excluded
74
+ 4. Fields with type `REFERENCE` can only be assigned IDs through their `ApiName` name
75
+ 2. **`Update` Mutation Queries**:
76
+ 1. **MUST** include the id of the entity to update
77
+ 2. **MUST** only include `updateable` fields
78
+ 3. Child relationships can't be set and **MUST** be excluded
79
+ 4. Fields with type `REFERENCE` can only be assigned IDs through their `ApiName` name
80
+ 3. **`Delete` Mutation Queries**:
81
+ 1. **MUST** include the id of the entity to delete
82
+
83
+ ## Mutation Queries Output Field Constraints
84
+
85
+ 1. **`Create` and `Update` Mutation Queries**:
86
+ 1. **MUST** exclude all child relationships
87
+ 2. **MUST** exclude all `REFERENCE` fields, unless accessed through their `ApiName` member (no navigation to referenced entity)
88
+ 3. Inaccessible fields will be reported as part of the `errors` attribute in the returned payload
89
+ 4. Child relationships **CAN'T** be queried as part of a mutation
90
+ 5. Fields with type `REFERENCE` can only be queried through their `ApiName` (no referenced entities navigation, no sub fields)
91
+ 2. **`Delete` Mutation Queries**:
92
+ 1. **MUST** only include the `Id` field
93
+
94
+ ## Mutations Chaining
95
+
96
+ It is possible to chain related mutations in a single query, using references to `Id` resulting from a previous mutation execution:
97
+
98
+ 1. **Ordering** - Mutation `B` can reference mutation `A` only if mutation `A` comes first in the query
99
+ 2. **Notation** - Use `SomeId: "@{A}"` in mutation `B` to set the `SomeId` field value to the `Id` produced by mutation `A` execution
100
+ 3. **IDs only** - This only works with IDs, and `@{A}` will always be interpreted as the `Id` produced by mutation `A`
101
+ 4. **Restrictions** - `A` needs to be either a `Create` or `Delete` mutation, this will fail for `Update`
102
+
103
+ ## Mutation Query Report Template
104
+
105
+ Input arguments:
106
+
107
+ - Required fields: FieldName1 (Type1), FieldName2 (Type2)...
108
+ - Other fields: FieldName3 (Type3)...
109
+ - Output fields: FieldNameA (TypeA), FieldNameB (TypeB)...
110
+
111
+ ## Mutation Query Templates
112
+
113
+ ```graphql
114
+ mutation mutateEntityName(
115
+ # arguments
116
+ ) {
117
+ uiapi {
118
+ EntityNameOperation(input: {
119
+ # the following is for `Create` and `Update` operations only
120
+ EntityName: {
121
+ # Input fields
122
+ }
123
+ # the following is for `Update` and `Delete` operations only
124
+ Id: ... # id here
125
+ }) {
126
+ # the following is for `Create` and `Update` operations only
127
+ Record {
128
+ # Output fields
129
+ }
130
+ # the following is for `Delete` operations only
131
+ Id: ... # id here
132
+ }
133
+ }
134
+ }
135
+ ```
136
+
137
+ ## Mutation Standalone (Default) Output Format - CLEAN CODE ONLY
138
+
139
+ If generating for LWC, the variable should provide the entire `input` argument:
140
+
141
+ ```javascript
142
+ const QUERY_NAME = `
143
+ mutation mutateEntity($input: EntityNameOperationInput!) {
144
+ uiapi {
145
+ EntityNameOperation(input: $input) {
146
+ # select output fields here depending on operation type
147
+ }
148
+ }
149
+ }
150
+ `;
151
+
152
+ const QUERY_VARIABLES = {
153
+ input: {
154
+ // The following is for `Create` and `Update` operations only
155
+ EntityName: {
156
+ // variables here
157
+ },
158
+ // The following is for `Update` and `Delete` operations only
159
+ Id: ... // id here
160
+ }
161
+ };
162
+ ```
163
+
164
+ **DO NOT INCLUDE:**
165
+
166
+ - Explanatory comments about the query
167
+ - Field descriptions
168
+ - Additional text about what the query does
169
+ - Workflow step descriptions
170
+
171
+ **ONLY INCLUDE:**
172
+
173
+ - Raw query string
174
+ - Variables object
175
+ - Nothing else
176
+
177
+ ## Mutation LWC Integration (Only When Requested) Output Format
178
+
179
+ When integrating within an LWC:
180
+
181
+ 1. You must use the `executeMutation` imperative adapter
182
+ 2. The first parameter must be the result of calling the `gql` tag function on the query
183
+ 3. Both the `executeMutation` imperative adapter and the `gql` tag function must be imported from the `lightning/graphql` package
184
+
185
+ ```javascript
186
+ import { LightningElement, wire } from 'lwc';
187
+ import { gql, executeMutation } from 'lightning/graphql';
188
+
189
+ export default class MyComponent extends LightningElement {
190
+ get mutationQuery() {
191
+ return gql`
192
+ mutation operationEntityName {
193
+ // mutation query here
194
+ }
195
+ `;
196
+ }
197
+
198
+ async mutateEntity() {
199
+ // executeMutation takes the mutation document as its FIRST argument and
200
+ // the options ({ variables }) as its SECOND. Passing a single
201
+ // { query, variables } object leaves the document undefined.
202
+ const result = await executeMutation(this.mutationQuery, {
203
+ variables: {
204
+ // variables here
205
+ },
206
+ });
207
+ // do something with the result
208
+ }
209
+ }
210
+ ```
211
+
212
+ **DO:**
213
+
214
+ - use the `executeMutation` imperative adapter to execute the query and retrieve the result
215
+ - use the `gql` tag function to wrap the GraphQL query before passing it to the imperative adapter
216
+
217
+ **DO NOT:**
218
+
219
+ - don't attempt to use the `executeMutation` adapter in a wired way
220
+
221
+ ## Generated Mutation Query Testing
222
+
223
+ **Triggering conditions** - **ALL CONDITIONS MUST VALIDATE\***
224
+
225
+ 1. Only if the [Mutation Query Generation Workflow](#mutation-query-generation-workflow) step global status is `SUCCESS` and you have a generated query
226
+ 2. Only if the query to generate is a mutation query
227
+
228
+ You will use the `scripts/test-lds-graphql-query.sh` script to test the query, passing the confirmed alias, the generated query, and related variables (if any).
229
+
230
+ **Workflow**
231
+
232
+ 1. **Report Step** - Explain that you are able to test the query using the same method used during introspection
233
+ 1. You **MUST** report the method you will use, based on the org alias confirmed during Step 2 of [generation-guide.md](generation-guide.md)
234
+ 2. **Interactive Step** - Ask the user whether they want you to test the query using the proposed method
235
+ 1. **WAIT** for the user's answer.
236
+ 3. **Input Arguments** - You **MUST** ask the user for the input arguments to use
237
+ 1. **WAIT** for the user's answer.
238
+ 4. **Test Query** - If the user are OK with you testing the query:
239
+ 1. Run `scripts/test-lds-graphql-query.sh USERNAME_OR_ALIAS 'QUERY' '<VARIABLES_JSON>'` to test the query
240
+ 5. **Result Analysis** - Retrieve the `data` and `errors` attributes from the returned payload, and report the result of the test as one of the following options:
241
+ 1. `PARTIAL` if `data` is not an empty object, but `errors` is not an empty list - Explanation: some of the queried fields are not accessible on mutations
242
+ 2. `FAILED` if `data` is an empty object - Explanation: the query is not valid
243
+ 3. `SUCCESS` if `errors` is an empty list
244
+ 6. **Remediation Step** - If status is not `SUCCESS`, use the [`FAILED`](#failed-status-handling-workflow) or [`PARTIAL`](#partial-status-handling-workflow) status handling workflows
245
+
246
+ ### `FAILED` Status Handling Workflow
247
+
248
+ The query is invalid:
249
+
250
+ 1. **Error Analysis** - Parse and categorize the specific error messages
251
+ 2. **Root Cause Identification** - Use error message to identify the root cause:
252
+ - **Execution** - Error contains `invalid cross reference id` or `entity is deleted`
253
+ - **Syntax** - Error contains `invalid syntax`
254
+ - **Validation** - Error contains `validation error`
255
+ - **Type** - Error contains `VariableTypeMismatch` or `UnknownType`
256
+ - **Navigation** - Error contains `is not currently available in mutation results`
257
+ - **API Version** - Query deals with updates, you're testing with Connect API and error contains `Cannot invoke JsonElement.isJsonObject()`
258
+ 3. **Targeted Resolution** - Depending on the root cause categorization
259
+ - **Execution** - You're trying to update or delete an unknown/no longer available entity: either create an entity first, if you have generated the related query, or ask for a valid entity id to use
260
+ - **Syntax** - Update the query using the error message information to fix the syntax errors
261
+ - **Validation** - This field's name is most probably invalid, ask user for clarification and **WAIT** for the user's answer
262
+ - **Type** - Use the error details and GraphQL schema to correct argument's type, and adjust variables accordingly
263
+ - **Navigation** - Use the [`PARTIAL` status handling workflow](#partial-status-handling-workflow) below
264
+ - **API Version** - `Record` selection is only available with API version 64 and higher, **report** the issue, and try again with API version 64
265
+ 4. **Test Again** - Resume the [query testing workflow](#generated-mutation-query-testing) with the updated query (increment and track attempt counter)
266
+ 5. **Escalation Path** - If targeted resolution fails after 2 attempts, ask for additional details and restart the entire GraphQL workflow, going again through the introspection phase
267
+
268
+ ### `PARTIAL` Status Handling Workflow
269
+
270
+ The query can be improved:
271
+
272
+ 1. Report the fields mentioned in the `errors` list
273
+ 2. Explain that these fields can't be queried as part of a mutation query
274
+ 3. Explain that the query might be considered as failing, as it will report errors
275
+ 4. Offer to remove the offending fields
276
+ 5. **WAIT** for the user's answer
277
+ 6. If they are OK with removing the fields restart the [generation workflow](#mutation-query-generation-workflow) with the new field list
@@ -0,0 +1,237 @@
1
+ # GraphQL Read Query Generation
2
+
3
+ **Triggering conditions**
4
+
5
+ 1. Only after Steps 1–4 of [generation-guide.md](generation-guide.md) have completed successfully (introspection produced a `SUCCESS` status with no unknown entities or fields)
6
+ 2. Only if the query to generate is a read query
7
+
8
+ ## Your Role
9
+
10
+ You are a GraphQL expert and your role is to help generate Salesforce-compatible GraphQL read queries once the exploration phase has completed.
11
+
12
+ If the introspection workflow in [generation-guide.md](generation-guide.md) has not been executed yet, you **MUST** run it first, and then return to read query generation.
13
+
14
+ You will leverage the context provided by the requesting user as well as the validated introspection results from [generation-guide.md](generation-guide.md) to generate the queries, and then test them against a live org using the bundled `scripts/test-lds-graphql-query.sh` script.
15
+
16
+ ## Read Query Generation Workflow
17
+
18
+ Strictly follow the rules below when generating the GraphQL read query:
19
+
20
+ 1. **No Proliferation** - Only generate for the explicitly requested fields, nothing else
21
+ 2. **Unique Query** - Leverage child relationships to query entities in one single query
22
+ 3. **Navigate Entities** - Always use `relationshipName` to access reference fields and child entities
23
+ 1. **Exception** - if the `relationshipName` field is null, you can't navigate the related entity, and will have to return the `Id` itself
24
+ 4. **Leverage Fragments** - Generate one fragment per possible type on polymorphic fields (field with `dataType="REFERENCE"` and more than one entry in `referenceToInfos` introspection attribute)
25
+ 5. **Type Consistency** - Make sure variables used as query arguments and their related fields share the same GraphQL type
26
+ 6. **Type Enforcement** - Make sure to leverage field type information from introspection and GraphQL schema to generate field access
27
+ 7. **Semi and anti joins** - Use the semi-join or anti-join templates to filter an entity with conditions on child entities
28
+ 8. **Query Generation** - Use the [template](#read-query-template) to generate the query
29
+ 1. **Exception** - if you're generating a query to retrieve **current user**, **connected user** or **authenticated user** information, you must use the `uiapi.currentUser` field, which takes **no arguments**, and returns a `User` field
30
+ 9. **Output Format** - Use the [standalone](#read-standalone-default-output-format---clean-code-only) or [LWC](#read-lwc-integration-only-when-requested-output-format) output format templates based on desired output
31
+ 10. **Test the Query** - Use the [Generated Read Query Testing](#generated-read-query-testing) workflow to test the generated query
32
+ 1. **Report First** - Always report first, using the proper output format, before testing
33
+
34
+ ## Read Query Template
35
+
36
+ ```graphql
37
+ query QueryName {
38
+ uiapi {
39
+ query {
40
+ EntityName(
41
+ # conditions here
42
+ ) {
43
+ edges {
44
+ node {
45
+ # Direct fields
46
+ FieldName { value }
47
+
48
+ # Non-polymorphic reference (single type)
49
+ RelationshipName {
50
+ Id
51
+ Name { value }
52
+ }
53
+
54
+ # Polymorphic reference (multiple types)
55
+ PolymorphicRelationshipName {
56
+ ...TypeAInfo
57
+ ...TypeBInfo
58
+ }
59
+
60
+ # Child relationship (subquery)
61
+ RelationshipName(
62
+ # conditions here
63
+ ) {
64
+ edges {
65
+ node {
66
+ # fields
67
+ }
68
+ }
69
+ }
70
+ }
71
+ }
72
+ }
73
+ }
74
+ }
75
+ }
76
+
77
+ fragment TypeAInfo on TypeA {
78
+ Id
79
+ SpecificFieldA { value }
80
+ }
81
+
82
+ fragment TypeBInfo on TypeB {
83
+ Id
84
+ SpecificFieldB { value }
85
+ }
86
+ ```
87
+
88
+ ## Semi-Join and Anti-Join Condition Template
89
+
90
+ Semi-joins (resp. anti-joins) condition leverage parent-child relationships and allow filtering the parent entity using a condition on child entities.
91
+ This is a standard `where` condition, on the parent entity's `Id`, expressed using the `inq` (resp. `ninq`, i.e. not `inq`) operator. This operator accepts two attributes:
92
+
93
+ - The child entity camelcase name to apply the condition on, with a value expressing the condition
94
+ - The field name on the child entity containing the parent entity `Id`, which is the `fieldName` from the `childRelationships` information for the child entity
95
+ - If the only condition is related child entity existence, you can use an `Id: { ne: null }` condition
96
+
97
+ ### Semi-Join Example - ParentEntity with at least one Matching ChildEntity
98
+
99
+ ```graphql
100
+ query testSemiJoin {
101
+ uiapi {
102
+ query {
103
+ ParentEntity(
104
+ where: {
105
+ Id: {
106
+ inq: {
107
+ ChildEntity: {
108
+ # standard conditions here
109
+ Name: { like: "test%" }
110
+ Type: { eq: "some value" }
111
+ }
112
+ ApiName: "parentIdFieldInChild"
113
+ }
114
+ }
115
+ }
116
+ ) {
117
+ edges {
118
+ node {
119
+ Id
120
+ Name {
121
+ value
122
+ }
123
+ }
124
+ }
125
+ }
126
+ }
127
+ }
128
+ }
129
+ ```
130
+
131
+ ### Anti-Join Example - ParentEntity with no Matching ChildEntity
132
+
133
+ Same example as the [Semi-Join Example](#semi-join-example---parententity-with-at-least-one-matching-childentity), but replacing the `inq` operator by the `ninq` one.
134
+
135
+ ## Read Standalone (Default) Output Format - CLEAN CODE ONLY
136
+
137
+ ```javascript
138
+ const QUERY_NAME = `
139
+ query GetData {
140
+ // query here
141
+ }
142
+ `;
143
+
144
+ const QUERY_VARIABLES = {
145
+ // variables here
146
+ };
147
+ ```
148
+
149
+ **DO NOT INCLUDE:**
150
+
151
+ - Explanatory comments about the query
152
+ - Field descriptions
153
+ - Additional text about what the query does
154
+ - Workflow step descriptions
155
+
156
+ **ONLY INCLUDE:**
157
+
158
+ - Raw query string
159
+ - Variables object
160
+ - Nothing else
161
+
162
+ ## Read LWC Integration (Only When Requested) Output Format
163
+
164
+ When integrating within an LWC:
165
+
166
+ 1. You must use the `graphql` wire adapter
167
+ 2. The first parameter must be the result of calling the `gql` tag function on the query
168
+ 3. Both the `graphql` wire adapter and the `gql` tag function must be imported from the `lightning/graphql` package
169
+
170
+ ```javascript
171
+ import { LightningElement, wire } from 'lwc';
172
+ import { gql, graphql } from 'lightning/graphql';
173
+
174
+ export default class MyComponent extends LightningElement {
175
+ get queryDef() {
176
+ return gql`
177
+ query getEntityName {
178
+ // query here
179
+ }
180
+ `;
181
+ }
182
+
183
+ @wire(graphql, {
184
+ query: '$queryDef',
185
+ variables: '$queryVariables',
186
+ })
187
+ wiredData({ data, error }) {
188
+ // handle result
189
+ }
190
+ }
191
+ ```
192
+
193
+ **DO:**
194
+
195
+ - use the `graphql` wire adapter to execute the query and wire the handling function
196
+ - use the `gql` tag function to wrap the GraphQL query before passing it to the wire adapter
197
+
198
+ **DO NOT:**
199
+
200
+ - don't attempt to use the `graphql` adapter in an imperative way
201
+
202
+ ## Generated Read Query Testing
203
+
204
+ **Triggering conditions** - **ALL CONDITIONS MUST VALIDATE\***
205
+
206
+ 1. Only if the [Read Query Generation Workflow](#read-query-generation-workflow) step global status is `SUCCESS` and you have a generated query
207
+ 2. Only if the query to generate is a read query
208
+
209
+ You will use the `scripts/test-lds-graphql-query.sh` script to test the query, passing the confirmed alias, the generated query, and related variables (if any).
210
+
211
+ **Workflow**
212
+
213
+ 1. **Report Step** - Explain that you are able to test the query using the same method used during introspection
214
+ 1. You **MUST** report the method you will use, based on the org alias confirmed during Step 2 of [generation-guide.md](generation-guide.md)
215
+ 2. **Interactive Step** - Ask the user whether they want you to test the query using the proposed method
216
+ 1. **WAIT** for the user's answer.
217
+ 3. **Test Query** - If the user are OK with you testing the query:
218
+ 1. Run `scripts/test-lds-graphql-query.sh USERNAME_OR_ALIAS 'QUERY' '<VARIABLES_JSON>'` to test the query
219
+ 2. Report the result of the test as `SUCCESS` if the query executed without error, or `FAILED` if you got errors
220
+ 3. If the query executed without any errors, but you received no data, then the query is valid, and the result of the test is `SUCCESS`
221
+ 4. **Remediation Step** - If status is `FAILED`, use the [`FAILED` status handling workflows](#failed-status-handling-workflow)
222
+
223
+ ### `FAILED` Status Handling Workflow
224
+
225
+ The query is invalid:
226
+
227
+ 1. **Error Analysis** - Parse and categorize the specific error messages
228
+ 2. **Root Cause Identification** - Use error message to identify the root cause:
229
+ - **Syntax** - Error contains `invalid syntax`
230
+ - **Validation** - Error contains `validation error`
231
+ - **Type** - Error contains `VariableTypeMismatch` or `UnknownType`
232
+ 3. **Targeted Resolution** - Depending on the root cause categorization
233
+ - **Syntax** - Update the query using the error message information to fix the syntax errors
234
+ - **Validation** - This field's name is most probably invalid, ask user for clarification and **WAIT** for the user's answer
235
+ - **Type** - Use the error details and GraphQL schema to correct argument's type, and adjust variables accordingly
236
+ 4. **Test Again** - Resume the [query testing workflow](#generated-read-query-testing) with the updated query (increment and track attempt counter)
237
+ 5. **Escalation Path** - If targeted resolution fails after 2 attempts, ask for additional details and restart the entire GraphQL workflow, going again through the introspection phase