@salesforce/webapp-template-app-react-b2c-sample-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/dist/.a4drules/skills/install-feature/SKILL.md +1 -1
- package/dist/CHANGELOG.md +11 -0
- package/dist/force-app/main/default/webapplications/appreactb2csample/.graphqlrc.yml +2 -0
- package/dist/force-app/main/default/webapplications/appreactb2csample/build/vite.config.js +19 -1
- package/dist/force-app/main/default/webapplications/appreactb2csample/codegen.yml +12 -0
- package/dist/force-app/main/default/webapplications/appreactb2csample/eslint.config.js +28 -0
- package/dist/force-app/main/default/webapplications/appreactb2csample/package-lock.json +7958 -2310
- package/dist/force-app/main/default/webapplications/appreactb2csample/package.json +16 -4
- package/dist/force-app/main/default/webapplications/appreactb2csample/scripts/get-graphql-schema.mjs +68 -0
- package/dist/force-app/main/default/webapplications/appreactb2csample/src/api/graphql-operations-types.ts +3 -1
- package/dist/force-app/main/default/webapplications/appreactb2csample/src/api/utils/accounts.ts +33 -0
- package/dist/force-app/main/default/webapplications/appreactb2csample/vite.config.ts +18 -1
- package/dist/package.json +1 -1
- package/package.json +2 -2
|
@@ -9,9 +9,12 @@
|
|
|
9
9
|
"build:e2e": "npm run build && node scripts/rewrite-e2e-assets.mjs",
|
|
10
10
|
"lint": "eslint .",
|
|
11
11
|
"preview": "vite preview",
|
|
12
|
-
"test": "vitest"
|
|
12
|
+
"test": "vitest",
|
|
13
|
+
"graphql:codegen": "graphql-codegen",
|
|
14
|
+
"graphql:schema": "node scripts/get-graphql-schema.mjs"
|
|
13
15
|
},
|
|
14
16
|
"dependencies": {
|
|
17
|
+
"@salesforce/sdk-data": "^1.11.2",
|
|
15
18
|
"@salesforce/webapp-experimental": "*",
|
|
16
19
|
"@tailwindcss/vite": "^4.1.17",
|
|
17
20
|
"react": "^19.2.0",
|
|
@@ -21,6 +24,12 @@
|
|
|
21
24
|
},
|
|
22
25
|
"devDependencies": {
|
|
23
26
|
"@eslint/js": "^9.39.1",
|
|
27
|
+
"@graphql-codegen/cli": "^6.1.0",
|
|
28
|
+
"@graphql-codegen/typescript": "^5.0.6",
|
|
29
|
+
"@graphql-codegen/typescript-operations": "^5.0.6",
|
|
30
|
+
"@graphql-eslint/eslint-plugin": "^4.1.0",
|
|
31
|
+
"@graphql-tools/utils": "^11.0.0",
|
|
32
|
+
"@playwright/test": "^1.49.0",
|
|
24
33
|
"@salesforce/vite-plugin-webapp-experimental": "*",
|
|
25
34
|
"@testing-library/jest-dom": "^6.6.3",
|
|
26
35
|
"@testing-library/react": "^16.1.0",
|
|
@@ -31,15 +40,18 @@
|
|
|
31
40
|
"@vitejs/plugin-react": "^5.1.1",
|
|
32
41
|
"@vitest/ui": "^4.0.17",
|
|
33
42
|
"eslint": "^9.39.1",
|
|
43
|
+
"eslint-plugin-react": "^7.37.2",
|
|
34
44
|
"eslint-plugin-react-hooks": "^7.0.1",
|
|
35
45
|
"eslint-plugin-react-refresh": "^0.4.24",
|
|
36
46
|
"globals": "^16.5.0",
|
|
47
|
+
"graphql": "^16.11.0",
|
|
48
|
+
"graphql-codegen-typescript-operation-types": "^2.0.2",
|
|
37
49
|
"jsdom": "^25.0.1",
|
|
50
|
+
"serve": "^14.2.5",
|
|
38
51
|
"typescript": "~5.9.3",
|
|
39
52
|
"typescript-eslint": "^8.46.4",
|
|
40
53
|
"vite": "^7.2.4",
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"serve": "^14.2.5"
|
|
54
|
+
"vite-plugin-graphql-codegen": "^3.6.3",
|
|
55
|
+
"vitest": "^4.0.17"
|
|
44
56
|
}
|
|
45
57
|
}
|
package/dist/force-app/main/default/webapplications/appreactb2csample/scripts/get-graphql-schema.mjs
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Downloads the full GraphQL schema from a connected Salesforce org via introspection.
|
|
3
|
+
*
|
|
4
|
+
* Usage:
|
|
5
|
+
* npm run graphql:schema
|
|
6
|
+
* node scripts/get-graphql-schema.mjs [output-path]
|
|
7
|
+
*
|
|
8
|
+
* The default output path matches the schema location expected by codegen.yml
|
|
9
|
+
* and .graphqlrc.yml so that codegen and IDE tooling resolve it automatically.
|
|
10
|
+
*/
|
|
11
|
+
import { writeFileSync } from 'node:fs';
|
|
12
|
+
import { resolve } from 'node:path';
|
|
13
|
+
import { getOrgInfo } from '@salesforce/webapp-experimental/app';
|
|
14
|
+
import { buildClientSchema, getIntrospectionQuery, printSchema } from 'graphql';
|
|
15
|
+
import { pruneSchema } from '@graphql-tools/utils';
|
|
16
|
+
|
|
17
|
+
const DEFAULT_SCHEMA_PATH = '../../../../../schema.graphql';
|
|
18
|
+
|
|
19
|
+
async function executeSalesforceGraphQLQuery(query, variables, operationName) {
|
|
20
|
+
const {
|
|
21
|
+
rawInstanceUrl: instanceUrl,
|
|
22
|
+
apiVersion,
|
|
23
|
+
accessToken,
|
|
24
|
+
} = await getOrgInfo();
|
|
25
|
+
|
|
26
|
+
const targetUrl = `${instanceUrl}/services/data/v${apiVersion}/graphql`;
|
|
27
|
+
|
|
28
|
+
console.log(`Executing introspection query against ${targetUrl}`);
|
|
29
|
+
const response = await fetch(targetUrl, {
|
|
30
|
+
method: 'POST',
|
|
31
|
+
headers: {
|
|
32
|
+
Authorization: `Bearer ${accessToken}`,
|
|
33
|
+
'Content-Type': 'application/json',
|
|
34
|
+
'X-Chatter-Entity-Encoding': 'false',
|
|
35
|
+
},
|
|
36
|
+
body: JSON.stringify({ query, variables, operationName }),
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
if (!response.ok) {
|
|
40
|
+
const errorText = await response.text();
|
|
41
|
+
throw new Error(
|
|
42
|
+
`Salesforce GraphQL request failed: ${response.status} ${response.statusText} - ${errorText}`
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return response.json();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
try {
|
|
50
|
+
const outputPath = resolve(process.argv[2] || DEFAULT_SCHEMA_PATH);
|
|
51
|
+
|
|
52
|
+
const introspectionResult = await executeSalesforceGraphQLQuery(
|
|
53
|
+
getIntrospectionQuery(),
|
|
54
|
+
{},
|
|
55
|
+
'IntrospectionQuery'
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
const schema = buildClientSchema(introspectionResult.data);
|
|
59
|
+
const prunedSchema = pruneSchema(schema);
|
|
60
|
+
const sdl = printSchema(prunedSchema);
|
|
61
|
+
|
|
62
|
+
writeFileSync(outputPath, sdl);
|
|
63
|
+
|
|
64
|
+
console.log(`Schema saved to ${outputPath}`);
|
|
65
|
+
} catch (error) {
|
|
66
|
+
console.error('Error:', error.message);
|
|
67
|
+
process.exit(1);
|
|
68
|
+
}
|
|
@@ -12,7 +12,9 @@ export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & {
|
|
|
12
12
|
export type MakeEmpty<
|
|
13
13
|
T extends { [key: string]: unknown },
|
|
14
14
|
K extends keyof T,
|
|
15
|
-
> = {
|
|
15
|
+
> = {
|
|
16
|
+
[_ in K]?: never;
|
|
17
|
+
};
|
|
16
18
|
export type Incremental<T> =
|
|
17
19
|
| T
|
|
18
20
|
| {
|
package/dist/force-app/main/default/webapplications/appreactb2csample/src/api/utils/accounts.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { executeGraphQL } from '@salesforce/webapp-experimental/api';
|
|
2
|
+
import HIGH_REVENUE_ACCOUNTS_QUERY from './query/highRevenueAccountsQuery.graphql?raw';
|
|
3
|
+
import type {
|
|
4
|
+
GetHighRevenueAccountsQuery,
|
|
5
|
+
GetHighRevenueAccountsQueryVariables,
|
|
6
|
+
} from '../graphql-operations-types';
|
|
7
|
+
|
|
8
|
+
type AccountNode = NonNullable<
|
|
9
|
+
NonNullable<
|
|
10
|
+
NonNullable<
|
|
11
|
+
NonNullable<
|
|
12
|
+
GetHighRevenueAccountsQuery['uiapi']['query']['Account']
|
|
13
|
+
>['edges']
|
|
14
|
+
>[number]
|
|
15
|
+
>['node']
|
|
16
|
+
>;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Fetch accounts with annual revenue greater than the specified amount
|
|
20
|
+
*
|
|
21
|
+
* @param minRevenue - Minimum annual revenue threshold (default: 100000)
|
|
22
|
+
* @returns Array of accounts matching the criteria
|
|
23
|
+
*/
|
|
24
|
+
export async function getHighRevenueAccounts(
|
|
25
|
+
variables: GetHighRevenueAccountsQueryVariables
|
|
26
|
+
): Promise<(AccountNode | null | undefined)[]> {
|
|
27
|
+
const response = await executeGraphQL<GetHighRevenueAccountsQuery>(
|
|
28
|
+
HIGH_REVENUE_ACCOUNTS_QUERY,
|
|
29
|
+
variables
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
return response.uiapi?.query?.Account?.edges?.map(edge => edge?.node) || [];
|
|
33
|
+
}
|
|
@@ -4,12 +4,29 @@ import path from 'path';
|
|
|
4
4
|
import { resolve } from 'path';
|
|
5
5
|
import tailwindcss from '@tailwindcss/vite';
|
|
6
6
|
import salesforce from '@salesforce/vite-plugin-webapp-experimental';
|
|
7
|
+
import codegen from 'vite-plugin-graphql-codegen';
|
|
7
8
|
|
|
8
9
|
export default defineConfig(({ mode }) => {
|
|
9
10
|
return {
|
|
10
11
|
// Ensure root base for e2e/static serve; plugin may override when deployed under a path
|
|
11
12
|
base: '/',
|
|
12
|
-
plugins: [
|
|
13
|
+
plugins: [
|
|
14
|
+
tailwindcss(),
|
|
15
|
+
react(),
|
|
16
|
+
salesforce(),
|
|
17
|
+
codegen({
|
|
18
|
+
// Path to the codegen config file
|
|
19
|
+
configFilePathOverride: resolve(__dirname, 'codegen.yml'),
|
|
20
|
+
// Run codegen on dev server start
|
|
21
|
+
runOnStart: true,
|
|
22
|
+
// Don't run codegen on build for now
|
|
23
|
+
runOnBuild: false,
|
|
24
|
+
// Enable file watcher during development
|
|
25
|
+
enableWatcher: true,
|
|
26
|
+
// Fail build if codegen errors
|
|
27
|
+
throwOnBuild: true,
|
|
28
|
+
}),
|
|
29
|
+
],
|
|
13
30
|
|
|
14
31
|
// Build configuration for MPA
|
|
15
32
|
build: {
|
package/dist/package.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/webapp-template-app-react-b2c-sample-experimental",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.36.0",
|
|
4
4
|
"description": "B2C sample app template with app shell",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"author": "",
|
|
@@ -24,5 +24,5 @@
|
|
|
24
24
|
"react-dom": "^19.2.1",
|
|
25
25
|
"react-router": "^7.10.1"
|
|
26
26
|
},
|
|
27
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "b777854a57e42c3f676507c4b1ad27e23fbbd0d0"
|
|
28
28
|
}
|