@salesforce/webapp-template-feature-graphql-experimental 1.35.2 → 1.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +52 -65
- package/package.json +6 -43
- package/rules/graphql-data-access-rule.md +5 -5
- package/skills/graphql-data-access/SKILL.md +17 -40
- package/skills/graphql-data-access/docs/explore-schema.md +3 -3
- package/dist/.a4drules/build-validation.md +0 -81
- package/dist/.a4drules/code-quality.md +0 -150
- package/dist/.a4drules/graphql/tools/knowledge/lds-explore-graphql-schema.md +0 -227
- package/dist/.a4drules/graphql/tools/knowledge/lds-generate-graphql-mutationquery.md +0 -212
- package/dist/.a4drules/graphql/tools/knowledge/lds-generate-graphql-readquery.md +0 -185
- package/dist/.a4drules/graphql/tools/knowledge/lds-guide-graphql.md +0 -205
- package/dist/.a4drules/graphql/tools/schemas/shared.graphqls +0 -1150
- package/dist/.a4drules/graphql.md +0 -408
- package/dist/.a4drules/images.md +0 -13
- package/dist/.a4drules/react.md +0 -361
- package/dist/.a4drules/react_image_processing.md +0 -45
- package/dist/.a4drules/skills/install-feature/SKILL.md +0 -67
- package/dist/.a4drules/skills/install-feature/scripts/copy-feature-assets.sh +0 -36
- package/dist/.a4drules/typescript.md +0 -224
- package/dist/.forceignore +0 -15
- package/dist/.husky/pre-commit +0 -4
- package/dist/.prettierignore +0 -11
- package/dist/.prettierrc +0 -17
- package/dist/CHANGELOG.md +0 -498
- package/dist/README.md +0 -18
- package/dist/config/project-scratch-def.json +0 -13
- package/dist/force-app/main/default/webapplications/feature-graphql/.graphqlrc.yml +0 -6
- package/dist/force-app/main/default/webapplications/feature-graphql/.prettierignore +0 -9
- package/dist/force-app/main/default/webapplications/feature-graphql/.prettierrc +0 -11
- package/dist/force-app/main/default/webapplications/feature-graphql/build/vite.config.d.ts +0 -2
- package/dist/force-app/main/default/webapplications/feature-graphql/build/vite.config.js +0 -76
- package/dist/force-app/main/default/webapplications/feature-graphql/e2e/app.spec.ts +0 -24
- package/dist/force-app/main/default/webapplications/feature-graphql/eslint.config.js +0 -113
- package/dist/force-app/main/default/webapplications/feature-graphql/feature-graphql.webapplication-meta.xml +0 -7
- package/dist/force-app/main/default/webapplications/feature-graphql/index.html +0 -13
- package/dist/force-app/main/default/webapplications/feature-graphql/package-lock.json +0 -11134
- package/dist/force-app/main/default/webapplications/feature-graphql/package.json +0 -52
- package/dist/force-app/main/default/webapplications/feature-graphql/playwright.config.ts +0 -24
- package/dist/force-app/main/default/webapplications/feature-graphql/scripts/rewrite-e2e-assets.mjs +0 -23
- package/dist/force-app/main/default/webapplications/feature-graphql/src/api/graphql-operations-types.ts +0 -118
- package/dist/force-app/main/default/webapplications/feature-graphql/src/api/graphql.test.ts +0 -91
- package/dist/force-app/main/default/webapplications/feature-graphql/src/api/graphql.ts +0 -35
- package/dist/force-app/main/default/webapplications/feature-graphql/src/api/utils/accounts.ts +0 -35
- package/dist/force-app/main/default/webapplications/feature-graphql/src/api/utils/query/highRevenueAccountsQuery.graphql +0 -29
- package/dist/force-app/main/default/webapplications/feature-graphql/src/api/utils/user.test.ts +0 -129
- package/dist/force-app/main/default/webapplications/feature-graphql/src/api/utils/user.ts +0 -53
- package/dist/force-app/main/default/webapplications/feature-graphql/src/app.tsx +0 -22
- package/dist/force-app/main/default/webapplications/feature-graphql/src/appLayout.tsx +0 -11
- package/dist/force-app/main/default/webapplications/feature-graphql/src/assets/icons/book.svg +0 -3
- package/dist/force-app/main/default/webapplications/feature-graphql/src/assets/icons/copy.svg +0 -4
- package/dist/force-app/main/default/webapplications/feature-graphql/src/assets/icons/rocket.svg +0 -3
- package/dist/force-app/main/default/webapplications/feature-graphql/src/assets/icons/star.svg +0 -3
- package/dist/force-app/main/default/webapplications/feature-graphql/src/assets/images/codey-1.png +0 -0
- package/dist/force-app/main/default/webapplications/feature-graphql/src/assets/images/codey-2.png +0 -0
- package/dist/force-app/main/default/webapplications/feature-graphql/src/assets/images/codey-3.png +0 -0
- package/dist/force-app/main/default/webapplications/feature-graphql/src/assets/images/vibe-codey.svg +0 -194
- package/dist/force-app/main/default/webapplications/feature-graphql/src/components/AccountsTable.tsx +0 -121
- package/dist/force-app/main/default/webapplications/feature-graphql/src/index.ts +0 -7
- package/dist/force-app/main/default/webapplications/feature-graphql/src/navigationMenu.tsx +0 -81
- package/dist/force-app/main/default/webapplications/feature-graphql/src/pages/About.tsx +0 -12
- package/dist/force-app/main/default/webapplications/feature-graphql/src/pages/AccountsPage.tsx +0 -19
- package/dist/force-app/main/default/webapplications/feature-graphql/src/pages/Home.tsx +0 -12
- package/dist/force-app/main/default/webapplications/feature-graphql/src/pages/NotFound.tsx +0 -18
- package/dist/force-app/main/default/webapplications/feature-graphql/src/pages/new.tsx +0 -10
- package/dist/force-app/main/default/webapplications/feature-graphql/src/router-utils.tsx +0 -34
- package/dist/force-app/main/default/webapplications/feature-graphql/src/routes.tsx +0 -48
- package/dist/force-app/main/default/webapplications/feature-graphql/src/styles/global.css +0 -13
- package/dist/force-app/main/default/webapplications/feature-graphql/tsconfig.json +0 -36
- package/dist/force-app/main/default/webapplications/feature-graphql/tsconfig.node.json +0 -13
- package/dist/force-app/main/default/webapplications/feature-graphql/vite-env.d.ts +0 -1
- package/dist/force-app/main/default/webapplications/feature-graphql/vite.config.ts +0 -69
- package/dist/force-app/main/default/webapplications/feature-graphql/vitest-env.d.ts +0 -2
- package/dist/force-app/main/default/webapplications/feature-graphql/vitest.config.ts +0 -11
- package/dist/force-app/main/default/webapplications/feature-graphql/vitest.setup.ts +0 -1
- package/dist/force-app/main/default/webapplications/feature-graphql/webapplication.json +0 -7
- package/dist/jest.config.js +0 -6
- package/dist/package.json +0 -38
- package/dist/scripts/apex/hello.apex +0 -10
- package/dist/scripts/soql/account.soql +0 -6
- package/dist/sfdx-project.json +0 -12
- package/skills/graphql-data-access/scripts/codegen.js +0 -15
- package/skills/graphql-data-access/scripts/get-graphql-schema.mjs +0 -59
- package/src/force-app/main/default/webapplications/feature-graphql/.graphqlrc.yml +0 -6
- package/src/force-app/main/default/webapplications/feature-graphql/src/api/graphql-operations-types.ts +0 -118
- package/src/force-app/main/default/webapplications/feature-graphql/src/api/graphql.test.ts +0 -91
- package/src/force-app/main/default/webapplications/feature-graphql/src/api/graphql.ts +0 -35
- package/src/force-app/main/default/webapplications/feature-graphql/src/api/utils/accounts.ts +0 -35
- package/src/force-app/main/default/webapplications/feature-graphql/src/api/utils/query/highRevenueAccountsQuery.graphql +0 -29
- package/src/force-app/main/default/webapplications/feature-graphql/src/api/utils/user.test.ts +0 -129
- package/src/force-app/main/default/webapplications/feature-graphql/src/api/utils/user.ts +0 -53
- package/src/force-app/main/default/webapplications/feature-graphql/src/components/AccountsTable.tsx +0 -121
- package/src/force-app/main/default/webapplications/feature-graphql/src/index.ts +0 -7
- package/src/force-app/main/default/webapplications/feature-graphql/src/pages/AccountsPage.tsx +0 -19
- package/src/force-app/main/default/webapplications/feature-graphql/src/routes.tsx +0 -20
- package/src/force-app/main/default/webapplications/feature-graphql/vite.config.ts +0 -69
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import type { RouteObject } from 'react-router';
|
|
2
|
-
import AppLayout from './appLayout';
|
|
3
|
-
import Home from './pages/Home';
|
|
4
|
-
import About from './pages/About';
|
|
5
|
-
import NotFound from './pages/NotFound';
|
|
6
|
-
import New from "./pages/new";
|
|
7
|
-
import AccountsPage from "./pages/AccountsPage";
|
|
8
|
-
|
|
9
|
-
export const routes: RouteObject[] = [
|
|
10
|
-
{
|
|
11
|
-
path: "/",
|
|
12
|
-
element: <AppLayout />,
|
|
13
|
-
children: [
|
|
14
|
-
{
|
|
15
|
-
index: true,
|
|
16
|
-
element: <Home />,
|
|
17
|
-
handle: { showInNavigation: true, label: 'Home' }
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
path: "about",
|
|
21
|
-
element: <About />,
|
|
22
|
-
handle: { showInNavigation: true, label: "About" }
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
path: '*',
|
|
26
|
-
element: <NotFound />
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
path: "contact",
|
|
30
|
-
element: <h1>Hello World from Contact Page</h1>,
|
|
31
|
-
handle: { showInNavigation: false }
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
path: "new",
|
|
35
|
-
element: <New />,
|
|
36
|
-
handle: { showInNavigation: true, label: "New Page" }
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
path: "accounts",
|
|
40
|
-
element: <AccountsPage />,
|
|
41
|
-
handle: {
|
|
42
|
-
showInNavigation: true,
|
|
43
|
-
label: "Accounts",
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
]
|
|
47
|
-
}
|
|
48
|
-
];
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2020",
|
|
4
|
-
"useDefineForClassFields": true,
|
|
5
|
-
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
|
6
|
-
"module": "ESNext",
|
|
7
|
-
"skipLibCheck": true,
|
|
8
|
-
|
|
9
|
-
/* Bundler mode */
|
|
10
|
-
"moduleResolution": "bundler",
|
|
11
|
-
"allowImportingTsExtensions": true,
|
|
12
|
-
"resolveJsonModule": true,
|
|
13
|
-
"isolatedModules": true,
|
|
14
|
-
"noEmit": true,
|
|
15
|
-
"jsx": "react-jsx",
|
|
16
|
-
|
|
17
|
-
/* Linting */
|
|
18
|
-
"strict": true,
|
|
19
|
-
"noUnusedLocals": true,
|
|
20
|
-
"noUnusedParameters": true,
|
|
21
|
-
"noFallthroughCasesInSwitch": true,
|
|
22
|
-
|
|
23
|
-
/* Path mapping */
|
|
24
|
-
"baseUrl": ".",
|
|
25
|
-
"paths": {
|
|
26
|
-
"@/*": ["./src/*"],
|
|
27
|
-
"@api/*": ["./src/api/*"],
|
|
28
|
-
"@components/*": ["./src/components/*"],
|
|
29
|
-
"@utils/*": ["./src/utils/*"],
|
|
30
|
-
"@styles/*": ["./src/styles/*"],
|
|
31
|
-
"@assets/*": ["./src/assets/*"]
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
"include": ["src", "vite-env.d.ts", "vitest-env.d.ts"],
|
|
35
|
-
"references": [{ "path": "./tsconfig.node.json" }]
|
|
36
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"composite": true,
|
|
4
|
-
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
|
|
5
|
-
"skipLibCheck": true,
|
|
6
|
-
"module": "ESNext",
|
|
7
|
-
"moduleResolution": "bundler",
|
|
8
|
-
"allowSyntheticDefaultImports": true,
|
|
9
|
-
"strict": true,
|
|
10
|
-
"outDir": "./build"
|
|
11
|
-
},
|
|
12
|
-
"include": ["vite.config.ts"]
|
|
13
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/// <reference types="vite/client" />
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from "vite";
|
|
2
|
-
import react from "@vitejs/plugin-react";
|
|
3
|
-
import path from "path";
|
|
4
|
-
import { resolve } from "path";
|
|
5
|
-
import tailwindcss from "@tailwindcss/vite";
|
|
6
|
-
import salesforce from "@salesforce/vite-plugin-webapp-experimental";
|
|
7
|
-
|
|
8
|
-
export default defineConfig(({ mode }) => {
|
|
9
|
-
return {
|
|
10
|
-
plugins: [tailwindcss(), react(), salesforce()],
|
|
11
|
-
|
|
12
|
-
build: {
|
|
13
|
-
outDir: resolve(__dirname, "dist"),
|
|
14
|
-
assetsDir: "assets",
|
|
15
|
-
sourcemap: false,
|
|
16
|
-
},
|
|
17
|
-
|
|
18
|
-
resolve: {
|
|
19
|
-
dedupe: ["react", "react-dom"],
|
|
20
|
-
alias: {
|
|
21
|
-
react: path.resolve(__dirname, "node_modules/react"),
|
|
22
|
-
"react-dom": path.resolve(__dirname, "node_modules/react-dom"),
|
|
23
|
-
"@": path.resolve(__dirname, "./src"),
|
|
24
|
-
"@api": path.resolve(__dirname, "./src/api"),
|
|
25
|
-
"@components": path.resolve(__dirname, "./src/components"),
|
|
26
|
-
"@utils": path.resolve(__dirname, "./src/utils"),
|
|
27
|
-
"@styles": path.resolve(__dirname, "./src/styles"),
|
|
28
|
-
"@assets": path.resolve(__dirname, "./src/assets"),
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
|
|
32
|
-
test: {
|
|
33
|
-
root: resolve(__dirname),
|
|
34
|
-
environment: "jsdom",
|
|
35
|
-
setupFiles: ["./src/test/setup.ts"],
|
|
36
|
-
include: [
|
|
37
|
-
"src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}",
|
|
38
|
-
"src/**/__tests__/**/*.{js,mjs,cjs,ts,mts,cts,jsx,tsx}",
|
|
39
|
-
],
|
|
40
|
-
coverage: {
|
|
41
|
-
provider: "v8",
|
|
42
|
-
reporter: ["text", "html", "clover", "json"],
|
|
43
|
-
exclude: [
|
|
44
|
-
"node_modules/",
|
|
45
|
-
"src/test/",
|
|
46
|
-
"src/**/*.d.ts",
|
|
47
|
-
"src/main.tsx",
|
|
48
|
-
"src/vite-env.d.ts",
|
|
49
|
-
"src/components/**/index.ts",
|
|
50
|
-
"**/*.config.ts",
|
|
51
|
-
"build/",
|
|
52
|
-
"dist/",
|
|
53
|
-
"coverage/",
|
|
54
|
-
"eslint.config.js",
|
|
55
|
-
],
|
|
56
|
-
thresholds: {
|
|
57
|
-
global: {
|
|
58
|
-
branches: 85,
|
|
59
|
-
functions: 85,
|
|
60
|
-
lines: 85,
|
|
61
|
-
statements: 85,
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
testTimeout: 10000,
|
|
66
|
-
globals: true,
|
|
67
|
-
},
|
|
68
|
-
};
|
|
69
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import '@testing-library/jest-dom/vitest';
|
package/dist/jest.config.js
DELETED
package/dist/package.json
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@salesforce/webapp-template-base-sfdx-project-experimental",
|
|
3
|
-
"version": "1.35.2",
|
|
4
|
-
"description": "Base SFDX project template",
|
|
5
|
-
"private": true,
|
|
6
|
-
"files": [
|
|
7
|
-
"dist"
|
|
8
|
-
],
|
|
9
|
-
"scripts": {
|
|
10
|
-
"build": "echo 'No build required for base-sfdx-project'",
|
|
11
|
-
"clean": "echo 'No clean required for base-sfdx-project'",
|
|
12
|
-
"lint": "eslint **/{aura,lwc}/**/*.js",
|
|
13
|
-
"test": "npm run test:unit",
|
|
14
|
-
"test:coverage": "npm run test",
|
|
15
|
-
"test:unit": "sfdx-lwc-jest -- --passWithNoTests",
|
|
16
|
-
"test:unit:watch": "sfdx-lwc-jest --watch",
|
|
17
|
-
"test:unit:debug": "sfdx-lwc-jest --debug",
|
|
18
|
-
"test:unit:coverage": "sfdx-lwc-jest --coverage",
|
|
19
|
-
"prettier": "prettier --write \"**/*.{cls,cmp,component,css,html,js,json,md,page,trigger,xml,yaml,yml}\"",
|
|
20
|
-
"prettier:verify": "prettier --check \"**/*.{cls,cmp,component,css,html,js,json,md,page,trigger,xml,yaml,yml}\"",
|
|
21
|
-
"precommit": "lint-staged"
|
|
22
|
-
},
|
|
23
|
-
"devDependencies": {
|
|
24
|
-
"@lwc/eslint-plugin-lwc": "^2.0.0",
|
|
25
|
-
"@prettier/plugin-xml": "^3.2.2",
|
|
26
|
-
"@salesforce/eslint-config-lwc": "^3.2.3",
|
|
27
|
-
"@salesforce/eslint-plugin-aura": "^2.0.0",
|
|
28
|
-
"@salesforce/eslint-plugin-lightning": "^1.0.0",
|
|
29
|
-
"@salesforce/sfdx-lwc-jest": "^7.0.1",
|
|
30
|
-
"eslint": "8.57.1",
|
|
31
|
-
"eslint-plugin-import": "^2.25.4",
|
|
32
|
-
"eslint-plugin-jest": "^28.8.1",
|
|
33
|
-
"husky": "^9.1.5",
|
|
34
|
-
"lint-staged": "^15.1.0",
|
|
35
|
-
"prettier": "^3.1.0",
|
|
36
|
-
"prettier-plugin-apex": "^2.0.1"
|
|
37
|
-
}
|
|
38
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
// Use .apex files to store anonymous Apex.
|
|
2
|
-
// You can execute anonymous Apex in VS Code by selecting the
|
|
3
|
-
// apex text and running the command:
|
|
4
|
-
// SFDX: Execute Anonymous Apex with Currently Selected Text
|
|
5
|
-
// You can also execute the entire file by running the command:
|
|
6
|
-
// SFDX: Execute Anonymous Apex with Editor Contents
|
|
7
|
-
|
|
8
|
-
string tempvar = 'Enter_your_name_here';
|
|
9
|
-
System.debug('Hello World!');
|
|
10
|
-
System.debug('My name is ' + tempvar);
|
package/dist/sfdx-project.json
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
schema: "../../schema.graphql",
|
|
3
|
-
documents: "./src/**/*.{graphql,ts,tsx}",
|
|
4
|
-
generates: {
|
|
5
|
-
"./src/api/graphql-operations-types.ts": {
|
|
6
|
-
plugins: ["graphql-codegen-typescript-operation-types", "typescript-operations"],
|
|
7
|
-
config: {
|
|
8
|
-
onlyOperationTypes: true,
|
|
9
|
-
skipTypename: true,
|
|
10
|
-
preResolveTypes: true,
|
|
11
|
-
},
|
|
12
|
-
},
|
|
13
|
-
},
|
|
14
|
-
overwrite: true,
|
|
15
|
-
};
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { writeFileSync } from "node:fs";
|
|
2
|
-
import { join, dirname } from "node:path";
|
|
3
|
-
import { fileURLToPath } from "node:url";
|
|
4
|
-
import { getOrgInfo } from "@salesforce/webapp-experimental/app";
|
|
5
|
-
import { buildClientSchema, getIntrospectionQuery, printSchema } from "graphql";
|
|
6
|
-
|
|
7
|
-
async function executeSalesforceGraphQLQuery(query, variables, operationName) {
|
|
8
|
-
const { rawInstanceUrl: instanceUrl, apiVersion, accessToken } = await getOrgInfo();
|
|
9
|
-
|
|
10
|
-
const targetUrl = `${instanceUrl}/services/data/v${apiVersion}/graphql`;
|
|
11
|
-
|
|
12
|
-
console.log(`[DEBUG] Executing GraphQL query: ${targetUrl}`);
|
|
13
|
-
const options = {
|
|
14
|
-
method: "POST",
|
|
15
|
-
headers: {
|
|
16
|
-
Authorization: `Bearer ${accessToken}`,
|
|
17
|
-
"Content-Type": "application/json",
|
|
18
|
-
"X-Chatter-Entity-Encoding": "false",
|
|
19
|
-
},
|
|
20
|
-
body: JSON.stringify({
|
|
21
|
-
query,
|
|
22
|
-
variables,
|
|
23
|
-
operationName,
|
|
24
|
-
}),
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
const response = await fetch(targetUrl, options);
|
|
28
|
-
|
|
29
|
-
if (!response.ok) {
|
|
30
|
-
const errorText = await response.text();
|
|
31
|
-
throw new Error(
|
|
32
|
-
`Salesforce GraphQL request failed: ${response.status} ${response.statusText} - ${errorText}`,
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return response.json();
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
try {
|
|
40
|
-
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
41
|
-
const outputPath = join(__dirname, "..", "..", "schema.graphql");
|
|
42
|
-
|
|
43
|
-
const introspectionResult = await executeSalesforceGraphQLQuery(
|
|
44
|
-
getIntrospectionQuery(),
|
|
45
|
-
{},
|
|
46
|
-
"IntrospectionQuery",
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
// Convert introspection JSON to SDL
|
|
50
|
-
const schema = buildClientSchema(introspectionResult.data);
|
|
51
|
-
const sdl = printSchema(schema);
|
|
52
|
-
|
|
53
|
-
writeFileSync(outputPath, sdl);
|
|
54
|
-
|
|
55
|
-
console.log(`[SUCCESS] Schema saved to ${outputPath}`);
|
|
56
|
-
} catch (error) {
|
|
57
|
-
console.error("[ERROR]", error.message);
|
|
58
|
-
process.exit(1);
|
|
59
|
-
}
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
export type Maybe<T> = T | null;
|
|
2
|
-
export type InputMaybe<T> = Maybe<T>;
|
|
3
|
-
export type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
|
|
4
|
-
export type MakeOptional<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]?: Maybe<T[SubKey]> };
|
|
5
|
-
export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]: Maybe<T[SubKey]> };
|
|
6
|
-
export type MakeEmpty<T extends { [key: string]: unknown }, K extends keyof T> = {
|
|
7
|
-
[_ in K]?: never;
|
|
8
|
-
};
|
|
9
|
-
export type Incremental<T> =
|
|
10
|
-
| T
|
|
11
|
-
| { [P in keyof T]?: P extends " $fragmentName" | "__typename" ? T[P] : never };
|
|
12
|
-
/** All built-in and custom scalars, mapped to their actual values */
|
|
13
|
-
export type Scalars = {
|
|
14
|
-
ID: { input: string; output: string };
|
|
15
|
-
String: { input: string; output: string };
|
|
16
|
-
Boolean: { input: boolean; output: boolean };
|
|
17
|
-
Int: { input: number; output: number };
|
|
18
|
-
Float: { input: number; output: number };
|
|
19
|
-
Base64: { input: any; output: any };
|
|
20
|
-
/** An arbitrary precision signed decimal */
|
|
21
|
-
BigDecimal: { input: any; output: any };
|
|
22
|
-
/** An arbitrary precision signed integer */
|
|
23
|
-
BigInteger: { input: any; output: any };
|
|
24
|
-
/** An 8-bit signed integer */
|
|
25
|
-
Byte: { input: any; output: any };
|
|
26
|
-
/** A UTF-16 code unit; a character on Unicode's BMP */
|
|
27
|
-
Char: { input: any; output: any };
|
|
28
|
-
Currency: { input: any; output: any };
|
|
29
|
-
Date: { input: any; output: any };
|
|
30
|
-
DateTime: { input: any; output: any };
|
|
31
|
-
Double: { input: any; output: any };
|
|
32
|
-
Email: { input: any; output: any };
|
|
33
|
-
EncryptedString: { input: any; output: any };
|
|
34
|
-
/** Can be set to an ID or a Reference to the result of another mutation operation. */
|
|
35
|
-
IdOrRef: { input: any; output: any };
|
|
36
|
-
JSON: { input: any; output: any };
|
|
37
|
-
Latitude: { input: any; output: any };
|
|
38
|
-
/** A 64-bit signed integer */
|
|
39
|
-
Long: { input: any; output: any };
|
|
40
|
-
LongTextArea: { input: any; output: any };
|
|
41
|
-
Longitude: { input: any; output: any };
|
|
42
|
-
MultiPicklist: { input: any; output: any };
|
|
43
|
-
Percent: { input: any; output: any };
|
|
44
|
-
PhoneNumber: { input: any; output: any };
|
|
45
|
-
Picklist: { input: any; output: any };
|
|
46
|
-
RichTextArea: { input: any; output: any };
|
|
47
|
-
/** A 16-bit signed integer */
|
|
48
|
-
Short: { input: any; output: any };
|
|
49
|
-
TextArea: { input: any; output: any };
|
|
50
|
-
Time: { input: any; output: any };
|
|
51
|
-
Url: { input: any; output: any };
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
export enum DataType {
|
|
55
|
-
Address = "ADDRESS",
|
|
56
|
-
Anytype = "ANYTYPE",
|
|
57
|
-
Base64 = "BASE64",
|
|
58
|
-
Boolean = "BOOLEAN",
|
|
59
|
-
Combobox = "COMBOBOX",
|
|
60
|
-
Complexvalue = "COMPLEXVALUE",
|
|
61
|
-
Currency = "CURRENCY",
|
|
62
|
-
Date = "DATE",
|
|
63
|
-
Datetime = "DATETIME",
|
|
64
|
-
Double = "DOUBLE",
|
|
65
|
-
Email = "EMAIL",
|
|
66
|
-
Encryptedstring = "ENCRYPTEDSTRING",
|
|
67
|
-
Int = "INT",
|
|
68
|
-
Json = "JSON",
|
|
69
|
-
Junctionidlist = "JUNCTIONIDLIST",
|
|
70
|
-
Location = "LOCATION",
|
|
71
|
-
Long = "LONG",
|
|
72
|
-
Multipicklist = "MULTIPICKLIST",
|
|
73
|
-
Percent = "PERCENT",
|
|
74
|
-
Phone = "PHONE",
|
|
75
|
-
Picklist = "PICKLIST",
|
|
76
|
-
Reference = "REFERENCE",
|
|
77
|
-
String = "STRING",
|
|
78
|
-
Textarea = "TEXTAREA",
|
|
79
|
-
Time = "TIME",
|
|
80
|
-
Url = "URL",
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export enum FieldExtraTypeInfo {
|
|
84
|
-
ExternalLookup = "EXTERNAL_LOOKUP",
|
|
85
|
-
ImageUrl = "IMAGE_URL",
|
|
86
|
-
IndirectLookup = "INDIRECT_LOOKUP",
|
|
87
|
-
Personname = "PERSONNAME",
|
|
88
|
-
Plaintextarea = "PLAINTEXTAREA",
|
|
89
|
-
Richtextarea = "RICHTEXTAREA",
|
|
90
|
-
SwitchablePersonname = "SWITCHABLE_PERSONNAME",
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export enum ResultOrder {
|
|
94
|
-
Asc = "ASC",
|
|
95
|
-
Desc = "DESC",
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
export type GetHighRevenueAccountsQueryVariables = Exact<{
|
|
99
|
-
minRevenue?: InputMaybe<Scalars["Currency"]["input"]>;
|
|
100
|
-
}>;
|
|
101
|
-
|
|
102
|
-
export type GetHighRevenueAccountsQuery = {
|
|
103
|
-
uiapi: {
|
|
104
|
-
query: {
|
|
105
|
-
Account?: {
|
|
106
|
-
edges?: Array<{
|
|
107
|
-
node?: {
|
|
108
|
-
Id: string;
|
|
109
|
-
Name?: { value?: string | null } | null;
|
|
110
|
-
AnnualRevenue?: { value?: any | null } | null;
|
|
111
|
-
Industry?: { value?: any | null } | null;
|
|
112
|
-
Website?: { value?: any | null } | null;
|
|
113
|
-
} | null;
|
|
114
|
-
} | null> | null;
|
|
115
|
-
} | null;
|
|
116
|
-
};
|
|
117
|
-
};
|
|
118
|
-
};
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
2
|
-
import { executeGraphQL } from "./graphql";
|
|
3
|
-
import { sdk } from "@salesforce/sdk-data";
|
|
4
|
-
|
|
5
|
-
vi.mock("@salesforce/sdk-data", () => ({
|
|
6
|
-
sdk: { graphql: vi.fn() },
|
|
7
|
-
}));
|
|
8
|
-
|
|
9
|
-
describe("executeGraphQL", () => {
|
|
10
|
-
beforeEach(() => {
|
|
11
|
-
vi.clearAllMocks();
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
it("should successfully execute a GraphQL query", async () => {
|
|
15
|
-
const mockData = {
|
|
16
|
-
uiapi: {
|
|
17
|
-
query: {
|
|
18
|
-
Account: {
|
|
19
|
-
edges: [
|
|
20
|
-
{
|
|
21
|
-
node: {
|
|
22
|
-
Id: "001",
|
|
23
|
-
Name: { value: "Test Account" },
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
],
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
vi.mocked(sdk.graphql!).mockResolvedValue({ data: mockData });
|
|
33
|
-
|
|
34
|
-
const query = "query { uiapi { query { Account { edges { node { Id Name { value } } } } } } }";
|
|
35
|
-
const result = await executeGraphQL(query);
|
|
36
|
-
|
|
37
|
-
expect(sdk.graphql).toHaveBeenCalledWith(query, undefined);
|
|
38
|
-
expect(result).toEqual(mockData);
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it("should handle GraphQL errors", async () => {
|
|
42
|
-
const mockErrors = [{ message: "Field not found" }, { message: "Invalid query" }];
|
|
43
|
-
|
|
44
|
-
vi.mocked(sdk.graphql!).mockResolvedValue({ errors: mockErrors } as any);
|
|
45
|
-
|
|
46
|
-
const query = "query { invalid }";
|
|
47
|
-
|
|
48
|
-
await expect(executeGraphQL(query)).rejects.toThrow(
|
|
49
|
-
"GraphQL Error: Field not found; Invalid query",
|
|
50
|
-
);
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it("should handle network errors", async () => {
|
|
54
|
-
vi.mocked(sdk.graphql!).mockRejectedValue({
|
|
55
|
-
status: 500,
|
|
56
|
-
message: "Network error",
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
const query = "query { test }";
|
|
60
|
-
|
|
61
|
-
await expect(executeGraphQL(query)).rejects.toThrow("Network error");
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it("should throw when data is undefined", async () => {
|
|
65
|
-
vi.mocked(sdk.graphql!).mockResolvedValue({} as any);
|
|
66
|
-
|
|
67
|
-
const query = "query { test }";
|
|
68
|
-
|
|
69
|
-
await expect(executeGraphQL(query)).rejects.toThrow("GraphQL Error: No data returned");
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
it("should throw when data is null", async () => {
|
|
73
|
-
vi.mocked(sdk.graphql!).mockResolvedValue({ data: null } as any);
|
|
74
|
-
|
|
75
|
-
const query = "query { test }";
|
|
76
|
-
|
|
77
|
-
await expect(executeGraphQL(query)).rejects.toThrow("GraphQL Error: No data returned");
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
it("should pass variables to the GraphQL query", async () => {
|
|
81
|
-
const mockData = { test: "data" };
|
|
82
|
-
vi.mocked(sdk.graphql!).mockResolvedValue({ data: mockData });
|
|
83
|
-
|
|
84
|
-
const query = "query GetAccount($id: ID!) { account(id: $id) { name } }";
|
|
85
|
-
const variables = { id: "001" };
|
|
86
|
-
|
|
87
|
-
await executeGraphQL(query, variables);
|
|
88
|
-
|
|
89
|
-
expect(sdk.graphql).toHaveBeenCalledWith(query, variables);
|
|
90
|
-
});
|
|
91
|
-
});
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { sdk } from "@salesforce/sdk-data";
|
|
2
|
-
|
|
3
|
-
export type NodeOfConnection<T> = T extends {
|
|
4
|
-
edges?: (infer E)[] | null;
|
|
5
|
-
} | null
|
|
6
|
-
? E extends { node?: infer N } | null
|
|
7
|
-
? N
|
|
8
|
-
: never
|
|
9
|
-
: never;
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Execute a GraphQL query against the Salesforce GraphQL API
|
|
13
|
-
*
|
|
14
|
-
* @param query - The GraphQL query string
|
|
15
|
-
* @param variables - Optional variables for the query
|
|
16
|
-
* @returns The GraphQL response data
|
|
17
|
-
*/
|
|
18
|
-
export async function executeGraphQL<T, InputVariables = Record<string, unknown>>(
|
|
19
|
-
query: string,
|
|
20
|
-
variables?: InputVariables,
|
|
21
|
-
): Promise<T> {
|
|
22
|
-
const result = await sdk.graphql!<T, InputVariables>(query, variables);
|
|
23
|
-
|
|
24
|
-
if (result.errors?.length) {
|
|
25
|
-
const errorMessages = result.errors.map((e) => e.message).join("; ");
|
|
26
|
-
throw new Error(`GraphQL Error: ${errorMessages}`);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (!result.data) {
|
|
30
|
-
throw new Error("GraphQL Error: No data returned");
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return result.data;
|
|
34
|
-
}
|
|
35
|
-
export { gql } from "@salesforce/sdk-data";
|
package/src/force-app/main/default/webapplications/feature-graphql/src/api/utils/accounts.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @attention agents
|
|
3
|
-
* This file serves as a reference example for accessing Salesforce data via GraphQL.
|
|
4
|
-
* Use this pattern when implementing new data fetching utilities:
|
|
5
|
-
* 1. Define TypeScript interfaces for the response shape
|
|
6
|
-
* 2. Write the GraphQL query using UIAPI syntax
|
|
7
|
-
* 3. Use executeGraphQL<T>() with proper typing
|
|
8
|
-
* 4. Extract and return the relevant data from the response
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import { executeGraphQL, type NodeOfConnection } from "../graphql";
|
|
12
|
-
import HIGH_REVENUE_ACCOUNTS_QUERY from "./query/highRevenueAccountsQuery.graphql?raw";
|
|
13
|
-
import type {
|
|
14
|
-
GetHighRevenueAccountsQuery,
|
|
15
|
-
GetHighRevenueAccountsQueryVariables,
|
|
16
|
-
} from "../graphql-operations-types";
|
|
17
|
-
|
|
18
|
-
type AccountNode = NodeOfConnection<GetHighRevenueAccountsQuery["uiapi"]["query"]["Account"]>;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Fetch accounts with annual revenue greater than the specified amount
|
|
22
|
-
*
|
|
23
|
-
* @param minRevenue - Minimum annual revenue threshold (default: 100000)
|
|
24
|
-
* @returns Array of accounts matching the criteria
|
|
25
|
-
*/
|
|
26
|
-
export async function getHighRevenueAccounts(
|
|
27
|
-
variables: GetHighRevenueAccountsQueryVariables,
|
|
28
|
-
): Promise<AccountNode[]> {
|
|
29
|
-
const response = await executeGraphQL<GetHighRevenueAccountsQuery>(
|
|
30
|
-
HIGH_REVENUE_ACCOUNTS_QUERY,
|
|
31
|
-
variables,
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
return response.uiapi?.query?.Account?.edges?.map((edge) => edge?.node) || [];
|
|
35
|
-
}
|