UNPKG

@salesforce/source-tracking

Version:

API for tracking local and remote Salesforce metadata changes

86 lines (85 loc) 3.79 kB
import { Logger, Org } from '@salesforce/core'; import { ChangeResult, RemoteChangeElement, RemoteSyncInput } from '../types'; export type PinoLogger = ReturnType<(typeof Logger)['getRawRootLogger']>; /** Options for RemoteSourceTrackingService.getInstance */ export type RemoteSourceTrackingServiceOptions = { org: Org; projectPath: string; }; export declare class RemoteSourceTrackingService { /** map of constructed, init'ed instances; key is orgId. It's like a singleton at the org level */ private static instanceMap; readonly filePath: string; private logger; private serverMaxRevisionCounter; private sourceMembers; private org; private queryCache; private userQueryCache; /** * Initializes the service with existing remote source tracking data, or sets * the state to begin source tracking of metadata changes in the org. */ private constructor(); /** * Get the singleton instance for a given user. * * @param {RemoteSourceTrackingService.Options} options that contain the org * @returns {Promise<RemoteSourceTrackingService>} the remoteSourceTrackingService object for the given username */ static getInstance(options: RemoteSourceTrackingServiceOptions): Promise<RemoteSourceTrackingService>; /** * Delete the RemoteSourceTracking for a given org. * * @param orgId * @returns the path of the deleted source tracking file */ static delete(orgId: string): Promise<string>; /** * pass in a series of SDR FilResponses .\ * it sets their last retrieved revision to the current revision counter from the server. */ syncSpecifiedElements(elements: RemoteSyncInput[]): Promise<void>; /** * Resets source tracking state by first clearing all tracked data, then * queries and synchronizes SourceMembers from the associated org. * * If a toRevision is passed, it will query for all `SourceMembers` with * a `RevisionCounter` less than or equal to the provided revision number. * * When no toRevision is passed, it will query and sync all `SourceMembers`. * * @param toRevision The `RevisionCounter` number to sync to. */ reset(toRevision?: number): Promise<string[]>; /** * Queries the org for any new, updated, or deleted metadata and updates * source tracking state. All `ChangeElements` not in sync with the org * are returned. */ retrieveUpdates(): Promise<RemoteChangeElement[]>; /** * Polls the org for SourceMember objects matching the provided metadata member names, * stopping when all members have been matched or the polling timeout is met or exceeded. * NOTE: This can be removed when the Team Dependency (TD-0085369) for W-7737094 is delivered. * * @param expectedMemberNames Array of metadata names to poll * @param pollingTimeout maximum amount of time in seconds to poll for SourceMembers */ pollForSourceTracking(expectedMembers: RemoteSyncInput[]): Promise<void>; /** * Adds the given SourceMembers to the list of tracked MemberRevisions, optionally updating * the lastRetrievedFromServer field (sync), and persists the changes to maxRevision.json. */ private trackSourceMembers; /** reads the tracking file and inits the logger and contents */ private init; /** Return a tracked element as MemberRevision data.*/ private getSourceMember; private setMemberRevision; } /** * pass in an RCE, and this will return a pullable ChangeResult. * Useful for correcing bundle types where the files show change results with types but aren't resolvable */ export declare const remoteChangeElementToChangeResult: (rce: RemoteChangeElement) => ChangeResult;