@squadbase/vite-server 0.1.7-dev.4 → 0.1.7-dev.6

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/cli/index.js CHANGED
@@ -85095,7 +85095,7 @@ var grafanaConnector = new ConnectorPlugin({
85095
85095
  description: "Connect to Grafana for monitoring dashboards, datasource queries, and alerting.",
85096
85096
  iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/3nGaPhV94lXQsHcCtv4mXz/0559d42f83066e8ba79e78410806750c/grafana-icon.webp",
85097
85097
  parameters: parameters58,
85098
- releaseFlag: { dev1: true, dev2: false, prod: false },
85098
+ releaseFlag: { dev1: true, dev2: true, prod: true },
85099
85099
  onboarding: grafanaOnboarding,
85100
85100
  systemPrompt: {
85101
85101
  en: `### Tools
@@ -86264,42 +86264,6 @@ await sentry.updateIssue("12345", { status: "resolved" });
86264
86264
 
86265
86265
  // ../connectors/src/connectors/salesforce/setup.ts
86266
86266
  var salesforceOnboarding = new ConnectorOnboarding({
86267
- connectionSetupInstructions: {
86268
- en: `#### Create a Connected App in Salesforce
86269
- 1. In Salesforce Setup, go to App Manager \u2192 New Connected App
86270
- 2. Under API (Enable OAuth Settings), check "Enable OAuth Settings"
86271
- 3. Add OAuth scopes: "Manage user data via APIs (api)" and "Perform requests at any time (refresh_token, offline_access)"
86272
- 4. Save and note the Consumer Key (client_id) and Consumer Secret (client_secret)
86273
-
86274
- #### Allow Username-Password Flow
86275
- 1. Go to Setup \u2192 Identity \u2192 OAuth and OpenID Connect Settings
86276
- 2. Enable "Allow OAuth Username-Password Flows"
86277
-
86278
- #### Reset your Security Token
86279
- 1. Go to Settings \u2192 My Personal Information \u2192 Reset My Security Token
86280
- 2. Salesforce emails you a new security token \u2014 append it to your password when entering the Password parameter (password + securityToken)
86281
-
86282
- #### Sandbox vs Production
86283
- - Leave Use Sandbox as "false" (or empty) to connect to production (login.salesforce.com)
86284
- - Set Use Sandbox to "true" to connect to a sandbox (test.salesforce.com)`,
86285
- ja: `#### Salesforce \u3067 Connected App \u3092\u4F5C\u6210
86286
- 1. Setup \u2192 App Manager \u2192 New Connected App
86287
- 2. API (Enable OAuth Settings) \u30BB\u30AF\u30B7\u30E7\u30F3\u3067 "Enable OAuth Settings" \u3092\u6709\u52B9\u5316
86288
- 3. OAuth \u30B9\u30B3\u30FC\u30D7\u306B "Manage user data via APIs (api)" \u3068 "Perform requests at any time (refresh_token, offline_access)" \u3092\u8FFD\u52A0
86289
- 4. \u4FDD\u5B58\u5F8C\u3001Consumer Key (client_id) \u3068 Consumer Secret (client_secret) \u3092\u63A7\u3048\u308B
86290
-
86291
- #### Username-Password Flow \u3092\u8A31\u53EF
86292
- 1. Setup \u2192 Identity \u2192 OAuth and OpenID Connect Settings
86293
- 2. "Allow OAuth Username-Password Flows" \u3092\u6709\u52B9\u5316
86294
-
86295
- #### Security Token \u306E\u767A\u884C
86296
- 1. \u500B\u4EBA\u8A2D\u5B9A \u2192 My Personal Information \u2192 Reset My Security Token
86297
- 2. Salesforce \u304B\u3089\u9001\u3089\u308C\u308B\u30BB\u30AD\u30E5\u30EA\u30C6\u30A3\u30C8\u30FC\u30AF\u30F3\u3092\u30D1\u30B9\u30EF\u30FC\u30C9\u306B\u9023\u7D50\u3057\u3066\u5165\u529B\uFF08password + securityToken\uFF09
86298
-
86299
- #### Sandbox / Production
86300
- - \u672C\u756A (login.salesforce.com) \u306E\u5834\u5408: Use Sandbox \u3092 "false" \u307E\u305F\u306F\u672A\u5165\u529B
86301
- - Sandbox (test.salesforce.com) \u306E\u5834\u5408: Use Sandbox \u3092 "true" \u306B\u8A2D\u5B9A`
86302
- },
86303
86267
  dataOverviewInstructions: {
86304
86268
  en: `1. Call salesforce_request with GET /services/data/v60.0/sobjects/ to list available sObjects (standard + custom)
86305
86269
  2. Call salesforce_request with GET /services/data/v60.0/sobjects/Account/describe to inspect Account fields; repeat for Contact, Opportunity, Lead as needed
@@ -86312,28 +86276,19 @@ var salesforceOnboarding = new ConnectorOnboarding({
86312
86276
 
86313
86277
  // ../connectors/src/connectors/salesforce/parameters.ts
86314
86278
  var parameters62 = {
86315
- username: new ParameterDefinition({
86316
- slug: "username",
86317
- name: "Username",
86318
- description: "Your Salesforce account username (the email you use to sign in).",
86319
- envVarBaseKey: "SALESFORCE_USERNAME",
86279
+ instanceUrl: new ParameterDefinition({
86280
+ slug: "instance-url",
86281
+ name: "Instance URL",
86282
+ description: "Your Salesforce org's My Domain URL (e.g., https://yourorg.my.salesforce.com). Find it under Setup \u2192 Company Settings \u2192 My Domain \u2192 Current My Domain URL.",
86283
+ envVarBaseKey: "SALESFORCE_INSTANCE_URL",
86320
86284
  type: "text",
86321
86285
  secret: false,
86322
86286
  required: true
86323
86287
  }),
86324
- password: new ParameterDefinition({
86325
- slug: "password",
86326
- name: "Password",
86327
- description: "Your Salesforce account password concatenated with your security token (password + securityToken). The security token is emailed to you when you reset it from Settings \u2192 My Personal Information \u2192 Reset My Security Token.",
86328
- envVarBaseKey: "SALESFORCE_PASSWORD",
86329
- type: "text",
86330
- secret: true,
86331
- required: true
86332
- }),
86333
86288
  clientId: new ParameterDefinition({
86334
86289
  slug: "client-id",
86335
86290
  name: "Consumer Key",
86336
- description: "The Consumer Key (client_id) of your Salesforce Connected App. Enable OAuth Settings and 'Allow OAuth Username-Password Flows' in your org's identity settings.",
86291
+ description: "The Consumer Key (client_id) of your External Client App (or Connected App). The app must enable the OAuth 2.0 Client Credentials Flow and bind a Run-As user with API access.",
86337
86292
  envVarBaseKey: "SALESFORCE_CLIENT_ID",
86338
86293
  type: "text",
86339
86294
  secret: false,
@@ -86342,20 +86297,11 @@ var parameters62 = {
86342
86297
  clientSecret: new ParameterDefinition({
86343
86298
  slug: "client-secret",
86344
86299
  name: "Consumer Secret",
86345
- description: "The Consumer Secret (client_secret) of your Salesforce Connected App.",
86300
+ description: "The Consumer Secret (client_secret) of your External Client App (or Connected App).",
86346
86301
  envVarBaseKey: "SALESFORCE_CLIENT_SECRET",
86347
86302
  type: "text",
86348
86303
  secret: true,
86349
86304
  required: true
86350
- }),
86351
- isSandbox: new ParameterDefinition({
86352
- slug: "is-sandbox",
86353
- name: "Use Sandbox",
86354
- description: 'Set to "true" to authenticate against a Salesforce sandbox (test.salesforce.com) instead of production (login.salesforce.com). Defaults to "false".',
86355
- envVarBaseKey: "SALESFORCE_IS_SANDBOX",
86356
- type: "text",
86357
- secret: false,
86358
- required: false
86359
86305
  })
86360
86306
  };
86361
86307
 
@@ -86386,10 +86332,17 @@ var outputSchema75 = z77.discriminatedUnion("success", [
86386
86332
  error: z77.string()
86387
86333
  })
86388
86334
  ]);
86335
+ function normalizeInstanceUrl(raw) {
86336
+ const trimmed = raw.trim().replace(/\/+$/, "");
86337
+ if (!/^https?:\/\//i.test(trimmed)) {
86338
+ return `https://${trimmed}`;
86339
+ }
86340
+ return trimmed;
86341
+ }
86389
86342
  var requestTool47 = new ConnectorTool({
86390
86343
  name: "request",
86391
86344
  description: `Send authenticated requests to the Salesforce REST API.
86392
- Authentication is handled automatically using the OAuth 2.0 username-password flow (Connected App Consumer Key + Secret with the Salesforce account credentials). An access token and instance URL are obtained on each request, so the tool user only provides the API path.
86345
+ Authentication is handled automatically using the OAuth 2.0 Client Credentials Flow (External Client App or Connected App Consumer Key + Secret). An access token is obtained on each request, so the tool user only provides the API path.
86393
86346
  Use this tool for all Salesforce interactions: describing sObjects, running SOQL queries (GET /services/data/vXX.X/query?q=...), reading/creating/updating standard (Account, Contact, Opportunity, Lead, Case) and custom objects.
86394
86347
  Prefer SOQL via the /query endpoint for filtered, joined, or aggregated reads rather than paginating /sobjects/{Type} endpoints.`,
86395
86348
  inputSchema: inputSchema75,
@@ -86406,20 +86359,16 @@ Prefer SOQL via the /query endpoint for filtered, joined, or aggregated reads ra
86406
86359
  `[connector-request] salesforce/${connection.name}: ${method} ${path5}`
86407
86360
  );
86408
86361
  try {
86409
- const username = parameters62.username.getValue(connection);
86410
- const password = parameters62.password.getValue(connection);
86362
+ const instanceUrlParam = parameters62.instanceUrl.getValue(connection);
86411
86363
  const clientId = parameters62.clientId.getValue(connection);
86412
86364
  const clientSecret = parameters62.clientSecret.getValue(connection);
86413
- const isSandbox = parameters62.isSandbox.tryGetValue(connection)?.toLowerCase() === "true";
86414
- const loginHost = isSandbox ? "https://test.salesforce.com" : "https://login.salesforce.com";
86365
+ const instanceUrl = normalizeInstanceUrl(instanceUrlParam);
86415
86366
  const tokenBody = new URLSearchParams({
86416
- grant_type: "password",
86367
+ grant_type: "client_credentials",
86417
86368
  client_id: clientId,
86418
- client_secret: clientSecret,
86419
- username,
86420
- password
86369
+ client_secret: clientSecret
86421
86370
  });
86422
- const tokenRes = await fetch(`${loginHost}/services/oauth2/token`, {
86371
+ const tokenRes = await fetch(`${instanceUrl}/services/oauth2/token`, {
86423
86372
  method: "POST",
86424
86373
  headers: {
86425
86374
  "Content-Type": "application/x-www-form-urlencoded"
@@ -86434,13 +86383,14 @@ Prefer SOQL via the /query endpoint for filtered, joined, or aggregated reads ra
86434
86383
  };
86435
86384
  }
86436
86385
  const tokenJson = await tokenRes.json();
86437
- if (!tokenJson.access_token || !tokenJson.instance_url) {
86386
+ if (!tokenJson.access_token) {
86438
86387
  return {
86439
86388
  success: false,
86440
- error: "access_token or instance_url not found in token response"
86389
+ error: "access_token not found in token response"
86441
86390
  };
86442
86391
  }
86443
- const url = `${tokenJson.instance_url}${path5.startsWith("/") ? "" : "/"}${path5}`;
86392
+ const resolvedInstanceUrl = tokenJson.instance_url ?? instanceUrl;
86393
+ const url = `${resolvedInstanceUrl}${path5.startsWith("/") ? "" : "/"}${path5}`;
86444
86394
  const controller = new AbortController();
86445
86395
  const timeout = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS59);
86446
86396
  try {
@@ -86489,7 +86439,7 @@ Prefer SOQL via the /query endpoint for filtered, joined, or aggregated reads ra
86489
86439
  var tools62 = { request: requestTool47 };
86490
86440
  var salesforceConnector = new ConnectorPlugin({
86491
86441
  slug: "salesforce",
86492
- authType: AUTH_TYPES.USER_PASSWORD,
86442
+ authType: AUTH_TYPES.API_KEY,
86493
86443
  name: "Salesforce",
86494
86444
  description: "Connect to Salesforce CRM for accounts, contacts, opportunities, leads, cases, and custom objects via SOQL and the REST API.",
86495
86445
  iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/6vZlbrUKhxXIiuvWJlb8YB/bbc5e08b88de46c8ed338a74c7d0abb3/salesforce-icon.png",
@@ -86499,7 +86449,7 @@ var salesforceConnector = new ConnectorPlugin({
86499
86449
  systemPrompt: {
86500
86450
  en: `### Tools
86501
86451
 
86502
- - \`salesforce_request\`: The only way to call the Salesforce REST API. Use it to run SOQL queries, describe sObjects, and read/create/update/delete standard (Account, Contact, Opportunity, Lead, Case) and custom objects. Authentication (OAuth 2.0 username-password flow against the Connected App) is configured automatically \u2014 an access token and the org's instance URL are resolved on each request. Prefer SOQL via \`GET /services/data/v60.0/query?q=...\` over paginating \`/sobjects/{Type}\` endpoints for filtered or joined reads.
86452
+ - \`salesforce_request\`: The only way to call the Salesforce REST API. Use it to run SOQL queries, describe sObjects, and read/create/update/delete standard (Account, Contact, Opportunity, Lead, Case) and custom objects. Authentication (OAuth 2.0 Client Credentials Flow against the External Client App / Connected App) is configured automatically \u2014 an access token is resolved on each request against the configured org instance URL. Prefer SOQL via \`GET /services/data/v60.0/query?q=...\` over paginating \`/sobjects/{Type}\` endpoints for filtered or joined reads.
86503
86453
 
86504
86454
  ### Business Logic
86505
86455
 
@@ -86545,9 +86495,8 @@ export default async function handler(c: Context) {
86545
86495
 
86546
86496
  ### Salesforce REST API Reference
86547
86497
 
86548
- - Login host: \`https://login.salesforce.com\` (production) or \`https://test.salesforce.com\` (sandbox)
86549
- - Token endpoint: \`POST /services/oauth2/token\` (grant_type=password + client_id/secret + username/password)
86550
- - Base path after login: \`{instance_url}/services/data/v60.0\`
86498
+ - Token endpoint: \`POST {instance_url}/services/oauth2/token\` (grant_type=client_credentials + client_id/secret)
86499
+ - Base path: \`{instance_url}/services/data/v60.0\` where instance_url is the org's My Domain URL
86551
86500
  - Authentication: Bearer token (handled automatically per request)
86552
86501
  - Pagination (SOQL): follow \`nextRecordsUrl\` from the response (absolute path starting with \`/services/data/v60.0/query/...\`)
86553
86502
 
@@ -86571,7 +86520,7 @@ export default async function handler(c: Context) {
86571
86520
  - Parent-to-child subquery: \`SELECT Id, Name, (SELECT Id, Email FROM Contacts) FROM Account\``,
86572
86521
  ja: `### \u30C4\u30FC\u30EB
86573
86522
 
86574
- - \`salesforce_request\`: Salesforce REST API \u3092\u547C\u3073\u51FA\u3059\u552F\u4E00\u306E\u624B\u6BB5\u3067\u3059\u3002SOQL \u30AF\u30A8\u30EA\u306E\u5B9F\u884C\u3001sObject \u306E describe\u3001\u6A19\u6E96\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\uFF08Account, Contact, Opportunity, Lead, Case\uFF09\u3084\u30AB\u30B9\u30BF\u30E0\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u306E\u8AAD\u307F\u66F8\u304D\u306B\u4F7F\u7528\u3057\u307E\u3059\u3002\u8A8D\u8A3C\uFF08Connected App + OAuth 2.0 Username-Password Flow\uFF09\u306F\u81EA\u52D5\u3067\u884C\u308F\u308C\u3001\u30EA\u30AF\u30A8\u30B9\u30C8\u3054\u3068\u306B\u30A2\u30AF\u30BB\u30B9\u30C8\u30FC\u30AF\u30F3\u3068\u7D44\u7E54\u306E instance URL \u304C\u89E3\u6C7A\u3055\u308C\u307E\u3059\u3002\u30D5\u30A3\u30EB\u30BF\u3084\u7D50\u5408\u306E\u3042\u308B\u8AAD\u307F\u53D6\u308A\u3067\u306F \`/sobjects/{Type}\` \u3092\u30DA\u30FC\u30B8\u30F3\u30B0\u3059\u308B\u306E\u3067\u306F\u306A\u304F\u3001\`GET /services/data/v60.0/query?q=...\` \u306E SOQL \u3092\u512A\u5148\u3057\u3066\u304F\u3060\u3055\u3044\u3002
86523
+ - \`salesforce_request\`: Salesforce REST API \u3092\u547C\u3073\u51FA\u3059\u552F\u4E00\u306E\u624B\u6BB5\u3067\u3059\u3002SOQL \u30AF\u30A8\u30EA\u306E\u5B9F\u884C\u3001sObject \u306E describe\u3001\u6A19\u6E96\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\uFF08Account, Contact, Opportunity, Lead, Case\uFF09\u3084\u30AB\u30B9\u30BF\u30E0\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u306E\u8AAD\u307F\u66F8\u304D\u306B\u4F7F\u7528\u3057\u307E\u3059\u3002\u8A8D\u8A3C\uFF08External Client App / Connected App + OAuth 2.0 Client Credentials Flow\uFF09\u306F\u81EA\u52D5\u3067\u884C\u308F\u308C\u3001\u8A2D\u5B9A\u3055\u308C\u305F\u7D44\u7E54\u306E instance URL \u306B\u5BFE\u3057\u3066\u30EA\u30AF\u30A8\u30B9\u30C8\u3054\u3068\u306B\u30A2\u30AF\u30BB\u30B9\u30C8\u30FC\u30AF\u30F3\u304C\u89E3\u6C7A\u3055\u308C\u307E\u3059\u3002\u30D5\u30A3\u30EB\u30BF\u3084\u7D50\u5408\u306E\u3042\u308B\u8AAD\u307F\u53D6\u308A\u3067\u306F \`/sobjects/{Type}\` \u3092\u30DA\u30FC\u30B8\u30F3\u30B0\u3059\u308B\u306E\u3067\u306F\u306A\u304F\u3001\`GET /services/data/v60.0/query?q=...\` \u306E SOQL \u3092\u512A\u5148\u3057\u3066\u304F\u3060\u3055\u3044\u3002
86575
86524
 
86576
86525
  ### Business Logic
86577
86526
 
@@ -86617,9 +86566,8 @@ export default async function handler(c: Context) {
86617
86566
 
86618
86567
  ### Salesforce REST API \u30EA\u30D5\u30A1\u30EC\u30F3\u30B9
86619
86568
 
86620
- - \u30ED\u30B0\u30A4\u30F3\u30DB\u30B9\u30C8: \`https://login.salesforce.com\`\uFF08\u672C\u756A\uFF09\u307E\u305F\u306F \`https://test.salesforce.com\`\uFF08Sandbox\uFF09
86621
- - \u30C8\u30FC\u30AF\u30F3\u30A8\u30F3\u30C9\u30DD\u30A4\u30F3\u30C8: \`POST /services/oauth2/token\`\uFF08grant_type=password + client_id/secret + username/password\uFF09
86622
- - \u30ED\u30B0\u30A4\u30F3\u5F8C\u306E\u30D9\u30FC\u30B9\u30D1\u30B9: \`{instance_url}/services/data/v60.0\`
86569
+ - \u30C8\u30FC\u30AF\u30F3\u30A8\u30F3\u30C9\u30DD\u30A4\u30F3\u30C8: \`POST {instance_url}/services/oauth2/token\`\uFF08grant_type=client_credentials + client_id/secret\uFF09
86570
+ - \u30D9\u30FC\u30B9\u30D1\u30B9: \`{instance_url}/services/data/v60.0\`\uFF08instance_url \u306F\u7D44\u7E54\u306E My Domain URL\uFF09
86623
86571
  - \u8A8D\u8A3C: Bearer \u30C8\u30FC\u30AF\u30F3\uFF08\u30EA\u30AF\u30A8\u30B9\u30C8\u3054\u3068\u306B\u81EA\u52D5\u8A2D\u5B9A\uFF09
86624
86572
  - \u30DA\u30FC\u30B8\u30CD\u30FC\u30B7\u30E7\u30F3\uFF08SOQL\uFF09: \u30EC\u30B9\u30DD\u30F3\u30B9\u306E \`nextRecordsUrl\`\uFF08\`/services/data/v60.0/query/...\` \u304B\u3089\u59CB\u307E\u308B\u7D76\u5BFE\u30D1\u30B9\uFF09\u3092\u8FBF\u308B
86625
86573
 
@@ -86861,7 +86809,7 @@ var influxdbConnector = new ConnectorPlugin({
86861
86809
  description: "Connect to InfluxDB (Cloud or OSS) to query time-series data with SQL, InfluxQL, or Flux and to write line protocol.",
86862
86810
  iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/J1JauVRNmahSVTVrpPfQK/18350d8d3f2dc3be25e8e36ee52914a0/influxdb.png",
86863
86811
  parameters: parameters63,
86864
- releaseFlag: { dev1: true, dev2: false, prod: false },
86812
+ releaseFlag: { dev1: true, dev2: true, prod: true },
86865
86813
  onboarding: influxdbOnboarding,
86866
86814
  systemPrompt: {
86867
86815
  en: `### Variant Detection
@@ -413,7 +413,7 @@ var grafanaConnector = new ConnectorPlugin({
413
413
  description: "Connect to Grafana for monitoring dashboards, datasource queries, and alerting.",
414
414
  iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/3nGaPhV94lXQsHcCtv4mXz/0559d42f83066e8ba79e78410806750c/grafana-icon.webp",
415
415
  parameters,
416
- releaseFlag: { dev1: true, dev2: false, prod: false },
416
+ releaseFlag: { dev1: true, dev2: true, prod: true },
417
417
  onboarding: grafanaOnboarding,
418
418
  systemPrompt: {
419
419
  en: `### Tools
@@ -519,7 +519,7 @@ var influxdbConnector = new ConnectorPlugin({
519
519
  description: "Connect to InfluxDB (Cloud or OSS) to query time-series data with SQL, InfluxQL, or Flux and to write line protocol.",
520
520
  iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/J1JauVRNmahSVTVrpPfQK/18350d8d3f2dc3be25e8e36ee52914a0/influxdb.png",
521
521
  parameters,
522
- releaseFlag: { dev1: true, dev2: false, prod: false },
522
+ releaseFlag: { dev1: true, dev2: true, prod: true },
523
523
  onboarding: influxdbOnboarding,
524
524
  systemPrompt: {
525
525
  en: `### Variant Detection
@@ -44,28 +44,19 @@ var ParameterDefinition = class {
44
44
 
45
45
  // ../connectors/src/connectors/salesforce/parameters.ts
46
46
  var parameters = {
47
- username: new ParameterDefinition({
48
- slug: "username",
49
- name: "Username",
50
- description: "Your Salesforce account username (the email you use to sign in).",
51
- envVarBaseKey: "SALESFORCE_USERNAME",
47
+ instanceUrl: new ParameterDefinition({
48
+ slug: "instance-url",
49
+ name: "Instance URL",
50
+ description: "Your Salesforce org's My Domain URL (e.g., https://yourorg.my.salesforce.com). Find it under Setup \u2192 Company Settings \u2192 My Domain \u2192 Current My Domain URL.",
51
+ envVarBaseKey: "SALESFORCE_INSTANCE_URL",
52
52
  type: "text",
53
53
  secret: false,
54
54
  required: true
55
55
  }),
56
- password: new ParameterDefinition({
57
- slug: "password",
58
- name: "Password",
59
- description: "Your Salesforce account password concatenated with your security token (password + securityToken). The security token is emailed to you when you reset it from Settings \u2192 My Personal Information \u2192 Reset My Security Token.",
60
- envVarBaseKey: "SALESFORCE_PASSWORD",
61
- type: "text",
62
- secret: true,
63
- required: true
64
- }),
65
56
  clientId: new ParameterDefinition({
66
57
  slug: "client-id",
67
58
  name: "Consumer Key",
68
- description: "The Consumer Key (client_id) of your Salesforce Connected App. Enable OAuth Settings and 'Allow OAuth Username-Password Flows' in your org's identity settings.",
59
+ description: "The Consumer Key (client_id) of your External Client App (or Connected App). The app must enable the OAuth 2.0 Client Credentials Flow and bind a Run-As user with API access.",
69
60
  envVarBaseKey: "SALESFORCE_CLIENT_ID",
70
61
  type: "text",
71
62
  secret: false,
@@ -74,34 +65,30 @@ var parameters = {
74
65
  clientSecret: new ParameterDefinition({
75
66
  slug: "client-secret",
76
67
  name: "Consumer Secret",
77
- description: "The Consumer Secret (client_secret) of your Salesforce Connected App.",
68
+ description: "The Consumer Secret (client_secret) of your External Client App (or Connected App).",
78
69
  envVarBaseKey: "SALESFORCE_CLIENT_SECRET",
79
70
  type: "text",
80
71
  secret: true,
81
72
  required: true
82
- }),
83
- isSandbox: new ParameterDefinition({
84
- slug: "is-sandbox",
85
- name: "Use Sandbox",
86
- description: 'Set to "true" to authenticate against a Salesforce sandbox (test.salesforce.com) instead of production (login.salesforce.com). Defaults to "false".',
87
- envVarBaseKey: "SALESFORCE_IS_SANDBOX",
88
- type: "text",
89
- secret: false,
90
- required: false
91
73
  })
92
74
  };
93
75
 
94
76
  // ../connectors/src/connectors/salesforce/sdk/index.ts
95
77
  var DEFAULT_API_VERSION = "60.0";
96
- async function fetchAccessToken(loginHost, clientId, clientSecret, username, password) {
78
+ function normalizeInstanceUrl(raw) {
79
+ const trimmed = raw.trim().replace(/\/+$/, "");
80
+ if (!/^https?:\/\//i.test(trimmed)) {
81
+ return `https://${trimmed}`;
82
+ }
83
+ return trimmed;
84
+ }
85
+ async function fetchAccessToken(instanceUrl, clientId, clientSecret) {
97
86
  const body = new URLSearchParams({
98
- grant_type: "password",
87
+ grant_type: "client_credentials",
99
88
  client_id: clientId,
100
- client_secret: clientSecret,
101
- username,
102
- password
89
+ client_secret: clientSecret
103
90
  });
104
- const res = await fetch(`${loginHost}/services/oauth2/token`, {
91
+ const res = await fetch(`${instanceUrl}/services/oauth2/token`, {
105
92
  method: "POST",
106
93
  headers: { "Content-Type": "application/x-www-form-urlencoded" },
107
94
  body: body.toString()
@@ -113,22 +100,22 @@ async function fetchAccessToken(loginHost, clientId, clientSecret, username, pas
113
100
  );
114
101
  }
115
102
  const json = await res.json();
116
- if (!json.access_token || !json.instance_url) {
103
+ if (!json.access_token) {
117
104
  throw new Error(
118
- "salesforce: access_token or instance_url not found in token response"
105
+ "salesforce: access_token not found in token response"
119
106
  );
120
107
  }
121
- return { accessToken: json.access_token, instanceUrl: json.instance_url };
108
+ return {
109
+ accessToken: json.access_token,
110
+ instanceUrl: json.instance_url ?? instanceUrl
111
+ };
122
112
  }
123
113
  function createClient(params) {
124
- const username = params[parameters.username.slug];
125
- const password = params[parameters.password.slug];
114
+ const instanceUrlParam = params[parameters.instanceUrl.slug];
126
115
  const clientId = params[parameters.clientId.slug];
127
116
  const clientSecret = params[parameters.clientSecret.slug];
128
- const isSandbox = (params[parameters.isSandbox.slug] ?? "").toLowerCase() === "true";
129
117
  for (const [slug, value] of [
130
- [parameters.username.slug, username],
131
- [parameters.password.slug, password],
118
+ [parameters.instanceUrl.slug, instanceUrlParam],
132
119
  [parameters.clientId.slug, clientId],
133
120
  [parameters.clientSecret.slug, clientSecret]
134
121
  ]) {
@@ -136,19 +123,13 @@ function createClient(params) {
136
123
  throw new Error(`salesforce: missing required parameter: ${slug}`);
137
124
  }
138
125
  }
139
- const loginHost = isSandbox ? "https://test.salesforce.com" : "https://login.salesforce.com";
126
+ const instanceUrl = normalizeInstanceUrl(instanceUrlParam);
140
127
  async function getToken() {
141
- return fetchAccessToken(
142
- loginHost,
143
- clientId,
144
- clientSecret,
145
- username,
146
- password
147
- );
128
+ return fetchAccessToken(instanceUrl, clientId, clientSecret);
148
129
  }
149
130
  async function authFetch(path2, init) {
150
- const { accessToken, instanceUrl } = await getToken();
151
- const url = path2.startsWith("http") ? path2 : `${instanceUrl}${path2.startsWith("/") ? "" : "/"}${path2}`;
131
+ const { accessToken, instanceUrl: resolvedInstanceUrl } = await getToken();
132
+ const url = path2.startsWith("http") ? path2 : `${resolvedInstanceUrl}${path2.startsWith("/") ? "" : "/"}${path2}`;
152
133
  const headers = new Headers(init?.headers);
153
134
  headers.set("Authorization", `Bearer ${accessToken}`);
154
135
  if (!headers.has("Content-Type") && init?.body) {
@@ -381,42 +362,6 @@ var AUTH_TYPES = {
381
362
 
382
363
  // ../connectors/src/connectors/salesforce/setup.ts
383
364
  var salesforceOnboarding = new ConnectorOnboarding({
384
- connectionSetupInstructions: {
385
- en: `#### Create a Connected App in Salesforce
386
- 1. In Salesforce Setup, go to App Manager \u2192 New Connected App
387
- 2. Under API (Enable OAuth Settings), check "Enable OAuth Settings"
388
- 3. Add OAuth scopes: "Manage user data via APIs (api)" and "Perform requests at any time (refresh_token, offline_access)"
389
- 4. Save and note the Consumer Key (client_id) and Consumer Secret (client_secret)
390
-
391
- #### Allow Username-Password Flow
392
- 1. Go to Setup \u2192 Identity \u2192 OAuth and OpenID Connect Settings
393
- 2. Enable "Allow OAuth Username-Password Flows"
394
-
395
- #### Reset your Security Token
396
- 1. Go to Settings \u2192 My Personal Information \u2192 Reset My Security Token
397
- 2. Salesforce emails you a new security token \u2014 append it to your password when entering the Password parameter (password + securityToken)
398
-
399
- #### Sandbox vs Production
400
- - Leave Use Sandbox as "false" (or empty) to connect to production (login.salesforce.com)
401
- - Set Use Sandbox to "true" to connect to a sandbox (test.salesforce.com)`,
402
- ja: `#### Salesforce \u3067 Connected App \u3092\u4F5C\u6210
403
- 1. Setup \u2192 App Manager \u2192 New Connected App
404
- 2. API (Enable OAuth Settings) \u30BB\u30AF\u30B7\u30E7\u30F3\u3067 "Enable OAuth Settings" \u3092\u6709\u52B9\u5316
405
- 3. OAuth \u30B9\u30B3\u30FC\u30D7\u306B "Manage user data via APIs (api)" \u3068 "Perform requests at any time (refresh_token, offline_access)" \u3092\u8FFD\u52A0
406
- 4. \u4FDD\u5B58\u5F8C\u3001Consumer Key (client_id) \u3068 Consumer Secret (client_secret) \u3092\u63A7\u3048\u308B
407
-
408
- #### Username-Password Flow \u3092\u8A31\u53EF
409
- 1. Setup \u2192 Identity \u2192 OAuth and OpenID Connect Settings
410
- 2. "Allow OAuth Username-Password Flows" \u3092\u6709\u52B9\u5316
411
-
412
- #### Security Token \u306E\u767A\u884C
413
- 1. \u500B\u4EBA\u8A2D\u5B9A \u2192 My Personal Information \u2192 Reset My Security Token
414
- 2. Salesforce \u304B\u3089\u9001\u3089\u308C\u308B\u30BB\u30AD\u30E5\u30EA\u30C6\u30A3\u30C8\u30FC\u30AF\u30F3\u3092\u30D1\u30B9\u30EF\u30FC\u30C9\u306B\u9023\u7D50\u3057\u3066\u5165\u529B\uFF08password + securityToken\uFF09
415
-
416
- #### Sandbox / Production
417
- - \u672C\u756A (login.salesforce.com) \u306E\u5834\u5408: Use Sandbox \u3092 "false" \u307E\u305F\u306F\u672A\u5165\u529B
418
- - Sandbox (test.salesforce.com) \u306E\u5834\u5408: Use Sandbox \u3092 "true" \u306B\u8A2D\u5B9A`
419
- },
420
365
  dataOverviewInstructions: {
421
366
  en: `1. Call salesforce_request with GET /services/data/v60.0/sobjects/ to list available sObjects (standard + custom)
422
367
  2. Call salesforce_request with GET /services/data/v60.0/sobjects/Account/describe to inspect Account fields; repeat for Contact, Opportunity, Lead as needed
@@ -454,10 +399,17 @@ var outputSchema = z.discriminatedUnion("success", [
454
399
  error: z.string()
455
400
  })
456
401
  ]);
402
+ function normalizeInstanceUrl2(raw) {
403
+ const trimmed = raw.trim().replace(/\/+$/, "");
404
+ if (!/^https?:\/\//i.test(trimmed)) {
405
+ return `https://${trimmed}`;
406
+ }
407
+ return trimmed;
408
+ }
457
409
  var requestTool = new ConnectorTool({
458
410
  name: "request",
459
411
  description: `Send authenticated requests to the Salesforce REST API.
460
- Authentication is handled automatically using the OAuth 2.0 username-password flow (Connected App Consumer Key + Secret with the Salesforce account credentials). An access token and instance URL are obtained on each request, so the tool user only provides the API path.
412
+ Authentication is handled automatically using the OAuth 2.0 Client Credentials Flow (External Client App or Connected App Consumer Key + Secret). An access token is obtained on each request, so the tool user only provides the API path.
461
413
  Use this tool for all Salesforce interactions: describing sObjects, running SOQL queries (GET /services/data/vXX.X/query?q=...), reading/creating/updating standard (Account, Contact, Opportunity, Lead, Case) and custom objects.
462
414
  Prefer SOQL via the /query endpoint for filtered, joined, or aggregated reads rather than paginating /sobjects/{Type} endpoints.`,
463
415
  inputSchema,
@@ -474,20 +426,16 @@ Prefer SOQL via the /query endpoint for filtered, joined, or aggregated reads ra
474
426
  `[connector-request] salesforce/${connection2.name}: ${method} ${path2}`
475
427
  );
476
428
  try {
477
- const username = parameters.username.getValue(connection2);
478
- const password = parameters.password.getValue(connection2);
429
+ const instanceUrlParam = parameters.instanceUrl.getValue(connection2);
479
430
  const clientId = parameters.clientId.getValue(connection2);
480
431
  const clientSecret = parameters.clientSecret.getValue(connection2);
481
- const isSandbox = parameters.isSandbox.tryGetValue(connection2)?.toLowerCase() === "true";
482
- const loginHost = isSandbox ? "https://test.salesforce.com" : "https://login.salesforce.com";
432
+ const instanceUrl = normalizeInstanceUrl2(instanceUrlParam);
483
433
  const tokenBody = new URLSearchParams({
484
- grant_type: "password",
434
+ grant_type: "client_credentials",
485
435
  client_id: clientId,
486
- client_secret: clientSecret,
487
- username,
488
- password
436
+ client_secret: clientSecret
489
437
  });
490
- const tokenRes = await fetch(`${loginHost}/services/oauth2/token`, {
438
+ const tokenRes = await fetch(`${instanceUrl}/services/oauth2/token`, {
491
439
  method: "POST",
492
440
  headers: {
493
441
  "Content-Type": "application/x-www-form-urlencoded"
@@ -502,13 +450,14 @@ Prefer SOQL via the /query endpoint for filtered, joined, or aggregated reads ra
502
450
  };
503
451
  }
504
452
  const tokenJson = await tokenRes.json();
505
- if (!tokenJson.access_token || !tokenJson.instance_url) {
453
+ if (!tokenJson.access_token) {
506
454
  return {
507
455
  success: false,
508
- error: "access_token or instance_url not found in token response"
456
+ error: "access_token not found in token response"
509
457
  };
510
458
  }
511
- const url = `${tokenJson.instance_url}${path2.startsWith("/") ? "" : "/"}${path2}`;
459
+ const resolvedInstanceUrl = tokenJson.instance_url ?? instanceUrl;
460
+ const url = `${resolvedInstanceUrl}${path2.startsWith("/") ? "" : "/"}${path2}`;
512
461
  const controller = new AbortController();
513
462
  const timeout = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
514
463
  try {
@@ -557,7 +506,7 @@ Prefer SOQL via the /query endpoint for filtered, joined, or aggregated reads ra
557
506
  var tools = { request: requestTool };
558
507
  var salesforceConnector = new ConnectorPlugin({
559
508
  slug: "salesforce",
560
- authType: AUTH_TYPES.USER_PASSWORD,
509
+ authType: AUTH_TYPES.API_KEY,
561
510
  name: "Salesforce",
562
511
  description: "Connect to Salesforce CRM for accounts, contacts, opportunities, leads, cases, and custom objects via SOQL and the REST API.",
563
512
  iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/6vZlbrUKhxXIiuvWJlb8YB/bbc5e08b88de46c8ed338a74c7d0abb3/salesforce-icon.png",
@@ -567,7 +516,7 @@ var salesforceConnector = new ConnectorPlugin({
567
516
  systemPrompt: {
568
517
  en: `### Tools
569
518
 
570
- - \`salesforce_request\`: The only way to call the Salesforce REST API. Use it to run SOQL queries, describe sObjects, and read/create/update/delete standard (Account, Contact, Opportunity, Lead, Case) and custom objects. Authentication (OAuth 2.0 username-password flow against the Connected App) is configured automatically \u2014 an access token and the org's instance URL are resolved on each request. Prefer SOQL via \`GET /services/data/v60.0/query?q=...\` over paginating \`/sobjects/{Type}\` endpoints for filtered or joined reads.
519
+ - \`salesforce_request\`: The only way to call the Salesforce REST API. Use it to run SOQL queries, describe sObjects, and read/create/update/delete standard (Account, Contact, Opportunity, Lead, Case) and custom objects. Authentication (OAuth 2.0 Client Credentials Flow against the External Client App / Connected App) is configured automatically \u2014 an access token is resolved on each request against the configured org instance URL. Prefer SOQL via \`GET /services/data/v60.0/query?q=...\` over paginating \`/sobjects/{Type}\` endpoints for filtered or joined reads.
571
520
 
572
521
  ### Business Logic
573
522
 
@@ -613,9 +562,8 @@ export default async function handler(c: Context) {
613
562
 
614
563
  ### Salesforce REST API Reference
615
564
 
616
- - Login host: \`https://login.salesforce.com\` (production) or \`https://test.salesforce.com\` (sandbox)
617
- - Token endpoint: \`POST /services/oauth2/token\` (grant_type=password + client_id/secret + username/password)
618
- - Base path after login: \`{instance_url}/services/data/v60.0\`
565
+ - Token endpoint: \`POST {instance_url}/services/oauth2/token\` (grant_type=client_credentials + client_id/secret)
566
+ - Base path: \`{instance_url}/services/data/v60.0\` where instance_url is the org's My Domain URL
619
567
  - Authentication: Bearer token (handled automatically per request)
620
568
  - Pagination (SOQL): follow \`nextRecordsUrl\` from the response (absolute path starting with \`/services/data/v60.0/query/...\`)
621
569
 
@@ -639,7 +587,7 @@ export default async function handler(c: Context) {
639
587
  - Parent-to-child subquery: \`SELECT Id, Name, (SELECT Id, Email FROM Contacts) FROM Account\``,
640
588
  ja: `### \u30C4\u30FC\u30EB
641
589
 
642
- - \`salesforce_request\`: Salesforce REST API \u3092\u547C\u3073\u51FA\u3059\u552F\u4E00\u306E\u624B\u6BB5\u3067\u3059\u3002SOQL \u30AF\u30A8\u30EA\u306E\u5B9F\u884C\u3001sObject \u306E describe\u3001\u6A19\u6E96\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\uFF08Account, Contact, Opportunity, Lead, Case\uFF09\u3084\u30AB\u30B9\u30BF\u30E0\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u306E\u8AAD\u307F\u66F8\u304D\u306B\u4F7F\u7528\u3057\u307E\u3059\u3002\u8A8D\u8A3C\uFF08Connected App + OAuth 2.0 Username-Password Flow\uFF09\u306F\u81EA\u52D5\u3067\u884C\u308F\u308C\u3001\u30EA\u30AF\u30A8\u30B9\u30C8\u3054\u3068\u306B\u30A2\u30AF\u30BB\u30B9\u30C8\u30FC\u30AF\u30F3\u3068\u7D44\u7E54\u306E instance URL \u304C\u89E3\u6C7A\u3055\u308C\u307E\u3059\u3002\u30D5\u30A3\u30EB\u30BF\u3084\u7D50\u5408\u306E\u3042\u308B\u8AAD\u307F\u53D6\u308A\u3067\u306F \`/sobjects/{Type}\` \u3092\u30DA\u30FC\u30B8\u30F3\u30B0\u3059\u308B\u306E\u3067\u306F\u306A\u304F\u3001\`GET /services/data/v60.0/query?q=...\` \u306E SOQL \u3092\u512A\u5148\u3057\u3066\u304F\u3060\u3055\u3044\u3002
590
+ - \`salesforce_request\`: Salesforce REST API \u3092\u547C\u3073\u51FA\u3059\u552F\u4E00\u306E\u624B\u6BB5\u3067\u3059\u3002SOQL \u30AF\u30A8\u30EA\u306E\u5B9F\u884C\u3001sObject \u306E describe\u3001\u6A19\u6E96\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\uFF08Account, Contact, Opportunity, Lead, Case\uFF09\u3084\u30AB\u30B9\u30BF\u30E0\u30AA\u30D6\u30B8\u30A7\u30AF\u30C8\u306E\u8AAD\u307F\u66F8\u304D\u306B\u4F7F\u7528\u3057\u307E\u3059\u3002\u8A8D\u8A3C\uFF08External Client App / Connected App + OAuth 2.0 Client Credentials Flow\uFF09\u306F\u81EA\u52D5\u3067\u884C\u308F\u308C\u3001\u8A2D\u5B9A\u3055\u308C\u305F\u7D44\u7E54\u306E instance URL \u306B\u5BFE\u3057\u3066\u30EA\u30AF\u30A8\u30B9\u30C8\u3054\u3068\u306B\u30A2\u30AF\u30BB\u30B9\u30C8\u30FC\u30AF\u30F3\u304C\u89E3\u6C7A\u3055\u308C\u307E\u3059\u3002\u30D5\u30A3\u30EB\u30BF\u3084\u7D50\u5408\u306E\u3042\u308B\u8AAD\u307F\u53D6\u308A\u3067\u306F \`/sobjects/{Type}\` \u3092\u30DA\u30FC\u30B8\u30F3\u30B0\u3059\u308B\u306E\u3067\u306F\u306A\u304F\u3001\`GET /services/data/v60.0/query?q=...\` \u306E SOQL \u3092\u512A\u5148\u3057\u3066\u304F\u3060\u3055\u3044\u3002
643
591
 
644
592
  ### Business Logic
645
593
 
@@ -685,9 +633,8 @@ export default async function handler(c: Context) {
685
633
 
686
634
  ### Salesforce REST API \u30EA\u30D5\u30A1\u30EC\u30F3\u30B9
687
635
 
688
- - \u30ED\u30B0\u30A4\u30F3\u30DB\u30B9\u30C8: \`https://login.salesforce.com\`\uFF08\u672C\u756A\uFF09\u307E\u305F\u306F \`https://test.salesforce.com\`\uFF08Sandbox\uFF09
689
- - \u30C8\u30FC\u30AF\u30F3\u30A8\u30F3\u30C9\u30DD\u30A4\u30F3\u30C8: \`POST /services/oauth2/token\`\uFF08grant_type=password + client_id/secret + username/password\uFF09
690
- - \u30ED\u30B0\u30A4\u30F3\u5F8C\u306E\u30D9\u30FC\u30B9\u30D1\u30B9: \`{instance_url}/services/data/v60.0\`
636
+ - \u30C8\u30FC\u30AF\u30F3\u30A8\u30F3\u30C9\u30DD\u30A4\u30F3\u30C8: \`POST {instance_url}/services/oauth2/token\`\uFF08grant_type=client_credentials + client_id/secret\uFF09
637
+ - \u30D9\u30FC\u30B9\u30D1\u30B9: \`{instance_url}/services/data/v60.0\`\uFF08instance_url \u306F\u7D44\u7E54\u306E My Domain URL\uFF09
691
638
  - \u8A8D\u8A3C: Bearer \u30C8\u30FC\u30AF\u30F3\uFF08\u30EA\u30AF\u30A8\u30B9\u30C8\u3054\u3068\u306B\u81EA\u52D5\u8A2D\u5B9A\uFF09
692
639
  - \u30DA\u30FC\u30B8\u30CD\u30FC\u30B7\u30E7\u30F3\uFF08SOQL\uFF09: \u30EC\u30B9\u30DD\u30F3\u30B9\u306E \`nextRecordsUrl\`\uFF08\`/services/data/v60.0/query/...\` \u304B\u3089\u59CB\u307E\u308B\u7D76\u5BFE\u30D1\u30B9\uFF09\u3092\u8FBF\u308B
693
640