@salesforce/core-bundle 8.17.0 → 8.18.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/lib/index.d.ts CHANGED
@@ -2667,6 +2667,8 @@ declare module '@salesforce/core-bundle/org/authInfo' {
2667
2667
  getFields(decrypt?: boolean): Readonly<AuthFields>;
2668
2668
  /**
2669
2669
  * Get the org front door (used for web based oauth flows)
2670
+ *
2671
+ * @deprecated Will be removed in the next major version. Use the `Org.getFrontDoorUrl()` method instead.
2670
2672
  */
2671
2673
  getOrgFrontDoorUrl(): string;
2672
2674
  /**
@@ -3225,6 +3227,39 @@ declare module '@salesforce/core-bundle/org/org' {
3225
3227
  * @ignore
3226
3228
  */
3227
3229
  constructor(options?: Org.Options);
3230
+ /**
3231
+ * Generate a URL to a metadata UI builder/setup section in an org.
3232
+ *
3233
+ * Bot: open in Agentforce Builder
3234
+ * ApexPage: opens page
3235
+ * Flow: open in Flow Builder
3236
+ * FlexiPage: open in Lightning App Builder
3237
+ * CustomObject: open in Object Manager
3238
+ * ApexClass: open in Setup -> Apex Classes UI
3239
+ *
3240
+ * if you pass any other metadata type you'll get a path to Lightning App Builder
3241
+ *
3242
+ * @example
3243
+ * // use SDR resolver:
3244
+ * import { MetadataResolver } from '@salesforce/source-deploy-retrieve';
3245
+ *
3246
+ * const metadataResolver = new MetadataResolver();
3247
+ * const components = metadataResolver.getComponentsFromPath(filePath);
3248
+ * const typeName = components[0]?.type?.name;
3249
+ *
3250
+ * const metadataBuilderUrl = await org.getMetadataUIURL(typeName, filePath);
3251
+ *
3252
+ * @typeName Bot | ApexPage | Flow | FlexiPage | CustomObject | ApexClass
3253
+ * @file Absolute file path to the metadata file
3254
+ */
3255
+ getMetadataUIURL(typeName: string, file: string): Promise<string>;
3256
+ /**
3257
+ * Get a Frontdoor URL
3258
+ *
3259
+ * This uses the UI Bridge API to generate a single-use Frontdoor URL:
3260
+ * https://help.salesforce.com/s/articleView?id=xcloud.frontdoor_singleaccess.htm&type=5
3261
+ */
3262
+ getFrontDoorUrl(redirectUri?: string): Promise<string>;
3228
3263
  /**
3229
3264
  * create a sandbox from a production org
3230
3265
  * 'this' needs to be a production org with sandbox licenses available
package/lib/index.js CHANGED
@@ -12336,7 +12336,7 @@ var require_package2 = __commonJS({
12336
12336
  "package.json"(exports2, module2) {
12337
12337
  module2.exports = {
12338
12338
  name: "@salesforce/core-bundle",
12339
- version: "8.17.0",
12339
+ version: "8.18.0",
12340
12340
  description: "Core libraries to interact with SFDX projects, orgs, and APIs.",
12341
12341
  main: "lib/index",
12342
12342
  types: "lib/index.d.ts",
@@ -12373,7 +12373,7 @@ var require_package2 = __commonJS({
12373
12373
  "messageTransformer/messageTransformer.ts"
12374
12374
  ],
12375
12375
  dependencies: {
12376
- "@jsforce/jsforce-node": "^3.8.2",
12376
+ "@jsforce/jsforce-node": "^3.9.1",
12377
12377
  "@salesforce/kit": "^3.2.2",
12378
12378
  "@salesforce/schemas": "^1.9.0",
12379
12379
  "@salesforce/ts-types": "^2.0.10",
@@ -33136,7 +33136,7 @@ var require_VERSION = __commonJS({
33136
33136
  "node_modules/@jsforce/jsforce-node/lib/VERSION.js"(exports2) {
33137
33137
  "use strict";
33138
33138
  Object.defineProperty(exports2, "__esModule", { value: true });
33139
- exports2.default = "3.8.2";
33139
+ exports2.default = "3.9.1";
33140
33140
  }
33141
33141
  });
33142
33142
 
@@ -46311,6 +46311,49 @@ var require_connection = __commonJS({
46311
46311
  * @param options
46312
46312
  */
46313
46313
  async upsert(type2, records, extIdField, options = {}) {
46314
+ return Array.isArray(records) ? (
46315
+ // check the version whether SObject collection API is supported (46.0)
46316
+ this._ensureVersion(46) ? this._upsertMany(type2, records, extIdField, options) : this._upsertParallel(type2, records, extIdField, options)
46317
+ ) : this._upsertParallel(type2, records, extIdField, options);
46318
+ }
46319
+ /** @private */
46320
+ async _upsertMany(type2, records, extIdField, options = {}) {
46321
+ if (records.length === 0) {
46322
+ return [];
46323
+ }
46324
+ if (records.length > MAX_DML_COUNT && options.allowRecursive) {
46325
+ return [
46326
+ ...await this._upsertMany(type2, records.slice(0, MAX_DML_COUNT), extIdField, options),
46327
+ ...await this._upsertMany(type2, records.slice(MAX_DML_COUNT), extIdField, options)
46328
+ ];
46329
+ }
46330
+ const _records = records.map((recordItem) => {
46331
+ const { [extIdField]: extId, type: recordType, attributes, ...rec } = recordItem;
46332
+ const sobjectType = recordType || attributes?.type || type2;
46333
+ if (!extId) {
46334
+ throw new Error("External ID is not found in record.");
46335
+ }
46336
+ if (!sobjectType) {
46337
+ throw new Error("No SObject Type defined in record");
46338
+ }
46339
+ return { [extIdField]: extId, attributes: { type: sobjectType }, ...rec };
46340
+ });
46341
+ const url = [this._baseUrl(), "composite", "sobjects", type2, extIdField].join("/");
46342
+ return this.request({
46343
+ method: "PATCH",
46344
+ url,
46345
+ body: JSON.stringify({
46346
+ allOrNone: options.allOrNone || false,
46347
+ records: _records
46348
+ }),
46349
+ headers: {
46350
+ ...options.headers || {},
46351
+ "content-type": "application/json"
46352
+ }
46353
+ });
46354
+ }
46355
+ /** @private */
46356
+ async _upsertParallel(type2, records, extIdField, options = {}) {
46314
46357
  const isArray = Array.isArray(records);
46315
46358
  const _records = Array.isArray(records) ? records : [records];
46316
46359
  if (_records.length > this._maxRequest) {
@@ -107816,10 +107859,13 @@ var require_org = __commonJS({
107816
107859
  __setModuleDefault2(result, mod);
107817
107860
  return result;
107818
107861
  };
107862
+ var __importDefault3 = exports2 && exports2.__importDefault || function(mod) {
107863
+ return mod && mod.__esModule ? mod : { "default": mod };
107864
+ };
107819
107865
  Object.defineProperty(exports2, "__esModule", { value: true });
107820
107866
  exports2.Org = exports2.SandboxEvents = exports2.OrgTypes = void 0;
107821
107867
  exports2.sandboxIsResumable = sandboxIsResumable;
107822
- var node_path_1 = require("node:path");
107868
+ var node_path_1 = __importDefault3(require("node:path"));
107823
107869
  var fs = __importStar2(require("node:fs"));
107824
107870
  var kit_1 = require_lib2();
107825
107871
  var ts_types_1 = require_lib();
@@ -107839,7 +107885,7 @@ var require_org = __commonJS({
107839
107885
  var authInfo_12 = require_authInfo();
107840
107886
  var scratchOrgCreate_12 = require_scratchOrgCreate();
107841
107887
  var orgConfigProperties_12 = require_orgConfigProperties();
107842
- var messages = new messages_12.Messages("@salesforce/core-bundle", "org", /* @__PURE__ */ new Map([["notADevHub", "The provided dev hub username %s is not a valid dev hub."], ["noUsernameFound", "No username found."], ["noDevHubFound", "Unable to associate this scratch org with a DevHub."], ["deleteOrgHubError", "The Dev Hub org cannot be deleted."], ["insufficientAccessToDelete", "You do not have the appropriate permissions to delete a scratch org. Please contact your Salesforce admin."], ["scratchOrgNotFound", "Attempting to delete an expired or deleted org"], ["sandboxDeleteFailed", "The sandbox org deletion failed with a result of %s."], ["sandboxNotFound", "We can't find a SandboxProcess for the sandbox %s."], ["sandboxInfoCreateFailed", "The sandbox org creation failed with a result of %s."], ["sandboxInfoRefreshFailed", "The sandbox org refresh failed with a result of %s."], ["missingAuthUsername", "The sandbox %s does not have an authorized username."], ["orgPollingTimeout", "Sandbox status is %s; timed out waiting for completion."], ["NotFoundOnDevHub", "The scratch org does not belong to the dev hub username %s."], ["AuthInfoOrgIdUndefined", "AuthInfo orgId is undefined."], ["sandboxCreateNotComplete", "The sandbox creation has not completed."], ["SandboxProcessNotFoundBySandboxName", "We can't find a SandboxProcess with the SandboxName %s."], ["MultiSandboxProcessNotFoundBySandboxName", "We found more than one SandboxProcess with the SandboxName %s."], ["sandboxNotResumable", "The sandbox %s cannot resume with status of %s."]]));
107888
+ var messages = new messages_12.Messages("@salesforce/core-bundle", "org", /* @__PURE__ */ new Map([["notADevHub", "The provided dev hub username %s is not a valid dev hub."], ["noUsernameFound", "No username found."], ["noDevHubFound", "Unable to associate this scratch org with a DevHub."], ["deleteOrgHubError", "The Dev Hub org cannot be deleted."], ["insufficientAccessToDelete", "You do not have the appropriate permissions to delete a scratch org. Please contact your Salesforce admin."], ["scratchOrgNotFound", "Attempting to delete an expired or deleted org"], ["sandboxDeleteFailed", "The sandbox org deletion failed with a result of %s."], ["sandboxNotFound", "We can't find a SandboxProcess for the sandbox %s."], ["sandboxInfoCreateFailed", "The sandbox org creation failed with a result of %s."], ["sandboxInfoRefreshFailed", "The sandbox org refresh failed with a result of %s."], ["missingAuthUsername", "The sandbox %s does not have an authorized username."], ["orgPollingTimeout", "Sandbox status is %s; timed out waiting for completion."], ["NotFoundOnDevHub", "The scratch org does not belong to the dev hub username %s."], ["AuthInfoOrgIdUndefined", "AuthInfo orgId is undefined."], ["sandboxCreateNotComplete", "The sandbox creation has not completed."], ["SandboxProcessNotFoundBySandboxName", "We can't find a SandboxProcess with the SandboxName %s."], ["MultiSandboxProcessNotFoundBySandboxName", "We found more than one SandboxProcess with the SandboxName %s."], ["sandboxNotResumable", "The sandbox %s cannot resume with status of %s."], ["FrontdoorURLError", "Failed to generate a frontdoor URL."], ["FlowIdNotFound", "ID not found for Flow %s."], ["CustomObjectIdNotFound", "ID not found for custom object %s."], ["ApexClassIdNotFound", "ID not found for Apex class %s."]]));
107843
107889
  var OrgTypes;
107844
107890
  (function(OrgTypes2) {
107845
107891
  OrgTypes2["Scratch"] = "scratch";
@@ -107906,6 +107952,105 @@ var require_org = __commonJS({
107906
107952
  super(options);
107907
107953
  this.options = options ?? {};
107908
107954
  }
107955
+ /**
107956
+ * Generate a URL to a metadata UI builder/setup section in an org.
107957
+ *
107958
+ * Bot: open in Agentforce Builder
107959
+ * ApexPage: opens page
107960
+ * Flow: open in Flow Builder
107961
+ * FlexiPage: open in Lightning App Builder
107962
+ * CustomObject: open in Object Manager
107963
+ * ApexClass: open in Setup -> Apex Classes UI
107964
+ *
107965
+ * if you pass any other metadata type you'll get a path to Lightning App Builder
107966
+ *
107967
+ * @example
107968
+ * // use SDR resolver:
107969
+ * import { MetadataResolver } from '@salesforce/source-deploy-retrieve';
107970
+ *
107971
+ * const metadataResolver = new MetadataResolver();
107972
+ * const components = metadataResolver.getComponentsFromPath(filePath);
107973
+ * const typeName = components[0]?.type?.name;
107974
+ *
107975
+ * const metadataBuilderUrl = await org.getMetadataUIURL(typeName, filePath);
107976
+ *
107977
+ * @typeName Bot | ApexPage | Flow | FlexiPage | CustomObject | ApexClass
107978
+ * @file Absolute file path to the metadata file
107979
+ */
107980
+ async getMetadataUIURL(typeName, file) {
107981
+ const botFileNameToId = async (conn, filePath) => (await conn.singleRecordQuery(`SELECT id FROM BotDefinition WHERE DeveloperName='${node_path_1.default.basename(filePath, ".bot-meta.xml")}'`)).Id;
107982
+ const flexiPageFilenameToId = async (conn, filePath) => (await conn.singleRecordQuery(`SELECT id FROM flexipage WHERE DeveloperName='${node_path_1.default.basename(filePath, ".flexipage-meta.xml")}'`, { tooling: true })).Id;
107983
+ const flowFileNameToId = async (conn, filePath) => {
107984
+ try {
107985
+ const flow = await conn.singleRecordQuery(`SELECT DurableId FROM FlowVersionView WHERE FlowDefinitionView.ApiName = '${node_path_1.default.basename(filePath, ".flow-meta.xml")}' ORDER BY VersionNumber DESC LIMIT 1`);
107986
+ return flow.DurableId;
107987
+ } catch (error) {
107988
+ throw messages.createError("FlowIdNotFound", [filePath]);
107989
+ }
107990
+ };
107991
+ const customObjectFileNameToId = async (conn, filePath) => {
107992
+ try {
107993
+ const customObject = await conn.singleRecordQuery(`SELECT Id FROM CustomObject WHERE DeveloperName = '${node_path_1.default.basename(filePath.replace(/__c/g, ""), ".object-meta.xml")}'`, {
107994
+ tooling: true
107995
+ });
107996
+ return customObject.Id;
107997
+ } catch (error) {
107998
+ throw messages.createError("CustomObjectIdNotFound", [filePath]);
107999
+ }
108000
+ };
108001
+ const apexClassFileNameToId = async (conn, filePath) => {
108002
+ try {
108003
+ const apexClass = await conn.singleRecordQuery(`SELECT Id FROM ApexClass WHERE Name = '${node_path_1.default.basename(filePath, ".cls")}'`, {
108004
+ tooling: true
108005
+ });
108006
+ return apexClass.Id;
108007
+ } catch (error) {
108008
+ throw messages.createError("ApexClassIdNotFound", [filePath]);
108009
+ }
108010
+ };
108011
+ let redirectUri = "";
108012
+ switch (typeName) {
108013
+ case "ApexClass":
108014
+ redirectUri = `lightning/setup/ApexClasses/page?address=%2F${await apexClassFileNameToId(this.connection, file)}`;
108015
+ break;
108016
+ case "CustomObject":
108017
+ redirectUri = `lightning/setup/ObjectManager/${await customObjectFileNameToId(this.connection, file)}/Details/view`;
108018
+ break;
108019
+ case "Bot":
108020
+ redirectUri = `/AiCopilot/copilotStudio.app#/copilot/builder?copilotId=${await botFileNameToId(this.connection, file)}`;
108021
+ break;
108022
+ case "ApexPage":
108023
+ redirectUri = `/apex/${node_path_1.default.basename(file).replace(".page-meta.xml", "").replace(".page", "")}`;
108024
+ break;
108025
+ case "Flow":
108026
+ redirectUri = `/builder_platform_interaction/flowBuilder.app?flowId=${await flowFileNameToId(this.connection, file)}`;
108027
+ break;
108028
+ case "FlexiPage":
108029
+ redirectUri = `/visualEditor/appBuilder.app?pageId=${await flexiPageFilenameToId(this.connection, file)}`;
108030
+ break;
108031
+ default:
108032
+ redirectUri = "/lightning/setup/FlexiPageList/home";
108033
+ break;
108034
+ }
108035
+ return this.getFrontDoorUrl(redirectUri);
108036
+ }
108037
+ /**
108038
+ * Get a Frontdoor URL
108039
+ *
108040
+ * This uses the UI Bridge API to generate a single-use Frontdoor URL:
108041
+ * https://help.salesforce.com/s/articleView?id=xcloud.frontdoor_singleaccess.htm&type=5
108042
+ */
108043
+ async getFrontDoorUrl(redirectUri) {
108044
+ await this.refreshAuth();
108045
+ const singleAccessUrl = new URL("/services/oauth2/singleaccess", this.connection.instanceUrl);
108046
+ if (redirectUri) {
108047
+ singleAccessUrl.searchParams.append("redirect_uri", redirectUri);
108048
+ }
108049
+ const response = await this.connection.requestGet(singleAccessUrl.toString());
108050
+ if (response.frontdoor_uri)
108051
+ return response.frontdoor_uri;
108052
+ throw new sfError_12.SfError(messages.getMessage("FrontdoorURLError")).setData(response);
108053
+ }
107909
108054
  /**
107910
108055
  * create a sandbox from a production org
107911
108056
  * 'this' needs to be a production org with sandbox licenses available
@@ -108629,7 +108774,7 @@ var require_org = __commonJS({
108629
108774
  }
108630
108775
  async getLocalDataDir(orgDataPath) {
108631
108776
  const rootFolder = await config_12.Config.resolveRootFolder(false);
108632
- return (0, node_path_1.join)(rootFolder, global_12.Global.SFDX_STATE_FOLDER, orgDataPath ? orgDataPath : "orgs");
108777
+ return node_path_1.default.join(rootFolder, global_12.Global.SFDX_STATE_FOLDER, orgDataPath ? orgDataPath : "orgs");
108633
108778
  }
108634
108779
  /**
108635
108780
  * Gets the sandboxProcessObject and then polls for it to complete.
@@ -109007,7 +109152,7 @@ var require_org = __commonJS({
109007
109152
  async removeSourceTrackingFiles() {
109008
109153
  try {
109009
109154
  const rootFolder = await config_12.Config.resolveRootFolder(false);
109010
- await fs.promises.rm((0, node_path_1.join)(rootFolder, global_12.Global.SF_STATE_FOLDER, "orgs", this.getOrgId()), {
109155
+ await fs.promises.rm(node_path_1.default.join(rootFolder, global_12.Global.SF_STATE_FOLDER, "orgs", this.getOrgId()), {
109011
109156
  recursive: true,
109012
109157
  force: true
109013
109158
  });
@@ -109520,6 +109665,8 @@ var require_authInfo = __commonJS({
109520
109665
  }
109521
109666
  /**
109522
109667
  * Get the org front door (used for web based oauth flows)
109668
+ *
109669
+ * @deprecated Will be removed in the next major version. Use the `Org.getFrontDoorUrl()` method instead.
109523
109670
  */
109524
109671
  getOrgFrontDoorUrl() {
109525
109672
  const authFields = this.getFields(true);
package/messages/org.md CHANGED
@@ -69,3 +69,19 @@ We found more than one SandboxProcess with the SandboxName %s.
69
69
  # sandboxNotResumable
70
70
 
71
71
  The sandbox %s cannot resume with status of %s.
72
+
73
+ # FrontdoorURLError
74
+
75
+ Failed to generate a frontdoor URL.
76
+
77
+ # FlowIdNotFound
78
+
79
+ ID not found for Flow %s.
80
+
81
+ # CustomObjectIdNotFound
82
+
83
+ ID not found for custom object %s.
84
+
85
+ # ApexClassIdNotFound
86
+
87
+ ID not found for Apex class %s.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/core-bundle",
3
- "version": "8.17.0",
3
+ "version": "8.18.0",
4
4
  "description": "Core libraries to interact with SFDX projects, orgs, and APIs.",
5
5
  "main": "lib/index",
6
6
  "types": "lib/index.d.ts",
@@ -37,7 +37,7 @@
37
37
  "messageTransformer/messageTransformer.ts"
38
38
  ],
39
39
  "dependencies": {
40
- "@jsforce/jsforce-node": "^3.8.2",
40
+ "@jsforce/jsforce-node": "^3.9.1",
41
41
  "@salesforce/kit": "^3.2.2",
42
42
  "@salesforce/schemas": "^1.9.0",
43
43
  "@salesforce/ts-types": "^2.0.10",