@salesforce/templates 66.10.1 → 66.10.3

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.
@@ -18,8 +18,8 @@
18
18
  "graphql:schema": "node scripts/get-graphql-schema.mjs"
19
19
  },
20
20
  "dependencies": {
21
- "@salesforce/platform-sdk": "^10.12.2",
22
- "@salesforce/ui-bundle": "^10.12.2",
21
+ "@salesforce/platform-sdk": "^10.19.0",
22
+ "@salesforce/ui-bundle": "^10.19.0",
23
23
  "@tailwindcss/vite": "^4.1.17",
24
24
  "class-variance-authority": "^0.7.1",
25
25
  "clsx": "^2.1.1",
@@ -45,7 +45,8 @@
45
45
  "@graphql-eslint/eslint-plugin": "^4.1.0",
46
46
  "@graphql-tools/utils": "^11.0.0",
47
47
  "@playwright/test": "^1.49.0",
48
- "@salesforce/vite-plugin-ui-bundle": "^10.12.2",
48
+ "@salesforce/graphiti": "^10.19.0",
49
+ "@salesforce/vite-plugin-ui-bundle": "^10.19.0",
49
50
  "@testing-library/jest-dom": "^6.6.3",
50
51
  "@testing-library/react": "^16.1.0",
51
52
  "@testing-library/user-event": "^14.5.2",
@@ -15,13 +15,16 @@ import { buildClientSchema, getIntrospectionQuery, printSchema } from 'graphql';
15
15
  import { pruneSchema } from '@graphql-tools/utils';
16
16
 
17
17
  const DEFAULT_SCHEMA_PATH = '../../../../../schema.graphql';
18
+ const TARGET_ORG = process.env.SF_TARGET_ORG || undefined;
18
19
 
19
20
  async function executeSalesforceGraphQLQuery(query, variables, operationName) {
20
- const {
21
- rawInstanceUrl: instanceUrl,
22
- apiVersion,
23
- accessToken,
24
- } = await getOrgInfo();
21
+ const orgInfo = await getOrgInfo(TARGET_ORG);
22
+ if (!orgInfo) {
23
+ throw new Error(
24
+ 'Could not resolve a Salesforce org. Set SF_TARGET_ORG or a default org.'
25
+ );
26
+ }
27
+ const { rawInstanceUrl: instanceUrl, apiVersion, accessToken } = orgInfo;
25
28
 
26
29
  const targetUrl = `${instanceUrl}/services/data/v${apiVersion}/graphql`;
27
30
 
@@ -1,19 +1,35 @@
1
1
  /**
2
- * Thin GraphQL client: createDataSDK + sdk.graphql.query with centralized
3
- * error handling. Use with gql-tagged queries and generated operation types
4
- * for type-safe calls.
2
+ * Thin GraphQL client: createDataSDK + sdk.graphql with centralized error
3
+ * handling. Mutations are routed to sdk.graphql.mutate and everything else to
4
+ * sdk.graphql.query (the SDK rejects an operation sent to the wrong method).
5
+ * Use with gql-tagged queries and generated operation types for type-safe calls.
5
6
  */
6
7
  import { createDataSDK } from '@salesforce/platform-sdk';
7
8
 
9
+ /**
10
+ * True when the operation's first definition is a `mutation`. Strips GraphQL
11
+ * comments first so a leading `# ...` line can't mask the keyword. Queries
12
+ * (named or anonymous `{ ... }` shorthand) and subscriptions fall through to
13
+ * query().
14
+ */
15
+ function isMutation(operation: string): boolean {
16
+ return /^\s*mutation\b/.test(operation.replace(/#[^\n\r]*/g, ''));
17
+ }
18
+
8
19
  export async function executeGraphQL<TData, TVariables>(
9
- query: string,
20
+ operation: string,
10
21
  variables?: TVariables
11
22
  ): Promise<TData> {
12
23
  const data = await createDataSDK();
13
- const result = await data.graphql!.query<TData, TVariables>({
14
- query: query,
15
- variables: variables,
16
- });
24
+ const result = isMutation(operation)
25
+ ? await data.graphql!.mutate<TData, TVariables>({
26
+ mutation: operation,
27
+ variables: variables,
28
+ })
29
+ : await data.graphql!.query<TData, TVariables>({
30
+ query: operation,
31
+ variables: variables,
32
+ });
17
33
 
18
34
  if (result.errors?.length) {
19
35
  const msg = result.errors.map(e => e.message).join('; ');
@@ -6,4 +6,8 @@
6
6
  </applicationVisibilities>
7
7
  <hasActivationRequired>false</hasActivationRequired>
8
8
  <label>reactinternalapp Access</label>
9
+ <userPermissions>
10
+ <enabled>true</enabled>
11
+ <name>ApiEnabled</name>
12
+ </userPermissions>
9
13
  </PermissionSet>
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/ui-bundle-template-base-sfdx-project",
3
- "version": "10.12.2",
3
+ "version": "10.19.0",
4
4
  "description": "Base SFDX project template",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "publishConfig": {
@@ -773,6 +773,7 @@ function run(name, cmd, args, opts = {}) {
773
773
  cwd,
774
774
  stdio: 'inherit',
775
775
  shell: true,
776
+ ...(opts.env && { env: opts.env }),
776
777
  ...(opts.timeout && { timeout: opts.timeout }),
777
778
  });
778
779
  if (result.status !== 0 && !optional) {
@@ -1140,8 +1141,10 @@ async function main() {
1140
1141
 
1141
1142
  if (!skipGraphql) {
1142
1143
  run('UI Bundle npm install', 'npm', ['install'], { cwd: uiBundleDir });
1143
- run('Set default org for schema', 'sf', ['config', 'set', 'target-org', targetOrg, '--global']);
1144
- run('GraphQL schema (introspect)', 'npm', ['run', 'graphql:schema'], { cwd: uiBundleDir });
1144
+ run('GraphQL schema (introspect)', 'npm', ['run', 'graphql:schema'], {
1145
+ cwd: uiBundleDir,
1146
+ env: { ...process.env, SF_TARGET_ORG: targetOrg },
1147
+ });
1145
1148
  run('GraphQL codegen', 'npm', ['run', 'graphql:codegen'], { cwd: uiBundleDir });
1146
1149
  run('UI Bundle build (post-codegen)', 'npm', ['run', 'build'], { cwd: uiBundleDir });
1147
1150
  } else if (!skipUIBundleBuild && skipDeploy) {