Skip to content

Commit eceed3f

Browse files
authored
feat: add support for rootTypesWithDependencies to RetrieveRequest (#1541)
1 parent 10dbbf1 commit eceed3f

File tree

4 files changed

+28
-0
lines changed

4 files changed

+28
-0
lines changed

src/client/metadataApiRetrieve.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ export class MetadataApiRetrieve extends MetadataTransfer<
245245
apiVersion: this.components?.sourceApiVersion ?? (await connection.retrieveMaxApiVersion()),
246246
...(manifestData ? { unpackaged: manifestData } : {}),
247247
...(this.options.singlePackage ? { singlePackage: this.options.singlePackage } : {}),
248+
...(this.options.rootTypesWithDependencies ? { rootTypesWithDependencies: this.options.rootTypesWithDependencies } : {}),
248249
// if we're retrieving with packageNames add it
249250
// otherwise don't - it causes errors if undefined or an empty array
250251
...(packageNames.length ? { packageNames } : {}),

src/client/types.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ export type DeployMessage = {
216216
export type RetrieveRequest = {
217217
apiVersion: string;
218218
packageNames?: string[];
219+
rootTypesWithDependencies?: string[];
219220
singlePackage?: boolean;
220221
specificFiles?: string[];
221222
unpackaged?: {
@@ -313,6 +314,11 @@ export type RetrieveOptions = {
313314
* A list of package names to retrieve, or package names and their retrieval locations.
314315
*/
315316
packageOptions?: PackageOptions;
317+
/**
318+
* An array of metadata type names for which related, dependent metadata
319+
* will be retrieved. At this time only `Bot` is supported.
320+
*/
321+
rootTypesWithDependencies?: string[];
316322
/**
317323
* The file format desired for the retrieved files.
318324
*/

test/client/metadataApiRetrieve.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,25 @@ describe('MetadataApiRetrieve', () => {
163163
});
164164
});
165165

166+
it('should call retrieve with rootTypesWithDependencies', async () => {
167+
const toRetrieve = new ComponentSet([COMPONENT]);
168+
const options = {
169+
toRetrieve,
170+
rootTypesWithDependencies: [ 'Bot' ],
171+
merge: true,
172+
successes: toRetrieve,
173+
};
174+
const { operation, retrieveStub } = await stubMetadataRetrieve($$, testOrg, options);
175+
await operation.start();
176+
177+
expect(retrieveStub.calledOnce).to.be.true;
178+
expect(retrieveStub.firstCall.args[0]).to.deep.equal({
179+
apiVersion: (await testOrg.getConnection()).getApiVersion(),
180+
rootTypesWithDependencies: options.rootTypesWithDependencies,
181+
unpackaged: (await toRetrieve.getObject()).Package,
182+
});
183+
});
184+
166185
it('should return an AsyncResult', async () => {
167186
const toRetrieve = new ComponentSet([COMPONENT]);
168187
const options = {

test/mock/client/transferOperations.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ type RetrieveStubOptions = {
156156
toRetrieve?: ComponentSet;
157157
messages?: Partial<RetrieveMessage> | Array<Partial<RetrieveMessage>>;
158158
successes?: ComponentSet;
159+
rootTypesWithDependencies?: string[];
159160
};
160161

161162
type RetrieveOperationLifecycle = {
@@ -321,6 +322,7 @@ export async function stubMetadataRetrieve(
321322
packageOptions: options.packageOptions,
322323
usernameOrConnection: connection,
323324
components: retrievedComponents,
325+
rootTypesWithDependencies: options.rootTypesWithDependencies,
324326
output: MOCK_DEFAULT_OUTPUT,
325327
registry: undefined,
326328
merge: options.merge,

0 commit comments

Comments
 (0)