@salesforce/core 8.14.1 → 8.15.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/org/org.d.ts CHANGED
@@ -5,6 +5,11 @@ import { OrgUsersConfig } from '../config/orgUsersConfig';
5
5
  import { Connection } from './connection';
6
6
  import { AuthFields, AuthInfo } from './authInfo';
7
7
  import { ScratchOrgCreateOptions, ScratchOrgCreateResult } from './scratchOrgCreate';
8
+ export type XOR<T, U> = (T & {
9
+ [K in keyof U]?: never;
10
+ }) | (U & {
11
+ [K in keyof T]?: never;
12
+ });
8
13
  export type OrganizationInformation = {
9
14
  Name: string;
10
15
  InstanceName: string;
@@ -59,6 +64,7 @@ export type SandboxProcessObject = {
59
64
  Description?: string;
60
65
  ApexClassId?: string;
61
66
  EndDate?: string;
67
+ Features?: string[];
62
68
  };
63
69
  export type SandboxRequest = {
64
70
  SandboxName: string;
@@ -68,6 +74,7 @@ export type SandboxRequest = {
68
74
  Description?: string;
69
75
  ApexClassId?: string;
70
76
  ActivationUserGroupId?: string;
77
+ Features?: string[];
71
78
  };
72
79
  export type ResumeSandboxRequest = {
73
80
  SandboxName?: string;
@@ -91,6 +98,7 @@ export type SandboxInfo = {
91
98
  SourceId?: string;
92
99
  ActivationUserGroupId?: string;
93
100
  CopyArchivedActivities?: boolean;
101
+ Features?: string[];
94
102
  };
95
103
  export type ScratchOrgRequest = Omit<ScratchOrgCreateOptions, 'hubOrg'>;
96
104
  export type SandboxFields = {
@@ -102,6 +110,11 @@ export type SandboxFields = {
102
110
  sandboxInfoId?: string;
103
111
  timestamp?: string;
104
112
  };
113
+ export type SandboxInfoQueryFields = XOR<{
114
+ name: string;
115
+ }, {
116
+ id: string;
117
+ }>;
105
118
  /**
106
119
  * Provides a way to manage a locally authenticated Org.
107
120
  *
@@ -313,6 +326,7 @@ export declare class Org extends AsyncOptionalCreatable<Org.Options> {
313
326
  * @returns org information
314
327
  */
315
328
  retrieveOrganizationInformation(): Promise<OrganizationInformation>;
329
+ querySandboxInfo(by: SandboxInfoQueryFields): Promise<SandboxInfo>;
316
330
  /**
317
331
  * Some organization information is locally cached, such as if the org name or if it is a scratch org.
318
332
  * This method populates/updates the filesystem from information retrieved from the org.
package/lib/org/org.js CHANGED
@@ -84,6 +84,26 @@ const sandboxProcessFields = [
84
84
  'SourceId',
85
85
  'Description',
86
86
  'EndDate',
87
+ 'Features',
88
+ ];
89
+ const sandboxInfoFields = [
90
+ 'Id',
91
+ 'IsDeleted',
92
+ 'CreatedDate',
93
+ 'CreatedById',
94
+ 'LastModifiedDate',
95
+ 'LastModifiedById',
96
+ 'SandboxName',
97
+ 'LicenseType',
98
+ 'TemplateId',
99
+ 'HistoryDays',
100
+ 'CopyChatter',
101
+ 'AutoActivate',
102
+ 'ApexClassId',
103
+ 'Description',
104
+ 'SourceId',
105
+ 'ActivationUserGroupId',
106
+ 'Features',
87
107
  ];
88
108
  /**
89
109
  * Provides a way to manage a locally authenticated Org.
@@ -597,6 +617,26 @@ class Org extends kit_1.AsyncOptionalCreatable {
597
617
  async retrieveOrganizationInformation() {
598
618
  return this.getConnection().singleRecordQuery('SELECT Name, InstanceName, IsSandbox, TrialExpirationDate, NamespacePrefix FROM Organization');
599
619
  }
620
+ async querySandboxInfo(by) {
621
+ if (by.id) {
622
+ // Validate that the ID is a valid Salesforce ID
623
+ if (!(0, sfdc_1.validateSalesforceId)(by.id)) {
624
+ throw new sfError_1.SfError(`Invalid Salesforce ID format: ${by.id}`, 'InvalidSalesforceId');
625
+ }
626
+ }
627
+ const whereClause = by.id ? `Id='${by.id}'` : `SandboxName='${by.name}'`;
628
+ const soql = `SELECT ${sandboxInfoFields.join(',')} FROM SandboxInfo WHERE ${whereClause} ORDER BY CreatedDate DESC`;
629
+ const result = (await this.connection.tooling.query(soql)).records.filter((item) => !item.IsDeleted);
630
+ if (result.length === 0) {
631
+ throw new sfError_1.SfError(`No record found for ${soql}`, connection_1.SingleRecordQueryErrors.NoRecords);
632
+ }
633
+ if (result.length > 1) {
634
+ const err = new sfError_1.SfError('The query returned more than 1 record', connection_1.SingleRecordQueryErrors.MultipleRecords);
635
+ err.data = result;
636
+ throw err;
637
+ }
638
+ return result[0];
639
+ }
600
640
  /**
601
641
  * Some organization information is locally cached, such as if the org name or if it is a scratch org.
602
642
  * This method populates/updates the filesystem from information retrieved from the org.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/core",
3
- "version": "8.14.1",
3
+ "version": "8.15.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",