-
Notifications
You must be signed in to change notification settings - Fork 118
/
Copy pathtypes.ts
384 lines (342 loc) · 9.46 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
/*
* Copyright (c) 2020, salesforce.com, inc.
* All rights reserved.
* Licensed under the BSD 3-Clause license.
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
import { RegistryAccess } from '../registry/registryAccess';
import { ComponentSet } from '../collections/componentSet';
import { PackageTypeMembers } from '../collections/types';
import { SourcePath } from '../common/types';
import { SourceComponent } from '../resolve/sourceComponent';
import { MetadataComponent } from '../resolve/types';
import { SfdxFileFormat } from '../convert/types';
import { MetadataTransferOptions } from './metadataTransfer';
// ------------------------------------------------
// API results reformatted for source development
// ------------------------------------------------
export type RecordId = string;
// TODO NEXT MAJOR: use a string union type
export enum ComponentStatus {
Created = 'Created',
Changed = 'Changed',
Unchanged = 'Unchanged',
Deleted = 'Deleted',
Failed = 'Failed',
}
export type ComponentDeployment = {
id?: string;
component: SourceComponent;
status: ComponentStatus;
diagnostics: ComponentDiagnostic[];
};
export type ComponentRetrieval = {
component: SourceComponent;
status?: RequestStatus;
diagnostics?: ComponentDiagnostic;
};
export type ComponentDiagnostic = {
lineNumber?: number;
columnNumber?: number;
filePath?: SourcePath;
error: string;
problemType: 'Warning' | 'Error';
};
type FileResponseBase = {
fullName: string;
type: string;
filePath?: string;
};
export type FileResponseSuccess = Required<FileResponseBase> & {
state: Exclude<ComponentStatus, ComponentStatus.Failed>;
};
export type FileResponseFailure = {
state: ComponentStatus.Failed;
lineNumber?: number;
columnNumber?: number;
error: string;
problemType: 'Warning' | 'Error';
} & FileResponseBase;
export type FileResponse = FileResponseSuccess | FileResponseFailure;
export type MetadataTransferResult = {
response: MetadataRequestStatus;
components?: ComponentSet;
getFileResponses(): FileResponse[];
};
export type AsyncResult = {
id: RecordId;
};
export enum RequestStatus {
Pending = 'Pending',
InProgress = 'InProgress',
Succeeded = 'Succeeded',
SucceededPartial = 'SucceededPartial',
Failed = 'Failed',
Canceling = 'Canceling',
Canceled = 'Canceled',
}
export type MetadataRequestStatus = {
id: string;
status: RequestStatus;
success: boolean;
done: boolean;
};
export type RetrieveFailure = {
component?: MetadataComponent;
message: string;
};
export type RetrieveSuccess = {
component: SourceComponent;
properties?: FileProperties;
};
// ------------------------------------------------
// Metadata API result types
// ------------------------------------------------
/**
* Raw response returned from a checkDeployStatus call to the Metadata API
*/
export type MetadataApiDeployStatus = {
canceledBy?: string;
canceledByName?: string;
checkOnly: boolean;
completedDate?: string;
createdBy: string;
createdByName: string;
createdDate: string;
details: DeployDetails;
errorMessage?: string;
errorStatusCode?: string;
ignoreWarnings: boolean;
lastModifiedDate: string;
numberComponentErrors: number;
numberComponentsDeployed: number;
numberComponentsTotal: number;
numberTestErrors: number;
numberTestsCompleted: number;
numberTestsTotal: number;
runTestsEnabled: boolean;
rollbackOnError: boolean;
startDate?: string;
stateDetail?: string;
} & MetadataRequestStatus;
export type DeployDetails = {
componentFailures?: DeployMessage | DeployMessage[];
componentSuccesses?: DeployMessage | DeployMessage[];
runTestResult?: RunTestResult;
};
export type RunTestResult = {
codeCoverage?: CodeCoverage[] | CodeCoverage;
codeCoverageWarnings?: CodeCoverageWarnings[] | CodeCoverageWarnings;
failures?: Failures[] | Failures;
numFailures: string;
numTestsRun: string;
successes?: Successes[] | Successes;
totalTime: string;
};
export type CodeCoverage = {
id: string;
locationsNotCovered?: LocationsNotCovered[] | LocationsNotCovered;
name: string;
numLocations: string;
numLocationsNotCovered: string;
type: string;
};
export type LocationsNotCovered = {
column: string;
line: string;
numExecutions: string;
time: string;
};
export type CodeCoverageWarnings = {
id: string;
message: string;
namespace: string;
};
export type Failures = {
id: string;
message: string;
methodName: string;
name: string;
packageName: string;
stackTrace: string;
time: string;
type: string;
};
export type Successes = {
id: string;
methodName: string;
name: string;
time: string;
};
export type BooleanString = 'true' | 'false' | true | false;
export type DeployMessage = {
changed: BooleanString;
columnNumber?: string;
componentType?: string;
created: BooleanString;
createdDate: string;
deleted: BooleanString;
fileName: string;
fullName: string;
id?: string;
lineNumber?: string;
problem?: string;
problemType?: 'Warning' | 'Error';
success: BooleanString;
};
export type RetrieveRequest = {
apiVersion: string;
packageNames?: string[];
singlePackage?: boolean;
specificFiles?: string[];
unpackaged?: {
types: PackageTypeMembers[];
};
};
export type RetrieveMessage = { fileName: string; problem: string };
export enum ManageableState {
Beta = 'beta',
Deleted = 'deleted',
Deprecated = 'deprecated',
DeprecatedEditable = 'deprecatedEditable',
Installed = 'installed',
InstalledEditable = 'installedEditable',
Released = 'released',
Unmanaged = 'unmanaged',
}
export type FileProperties = {
createdById: string;
createdByName: string;
createdDate: string;
fileName: string;
fullName: string;
id: string;
lastModifiedById: string;
lastModifiedByName: string;
lastModifiedDate: string;
manageableState?: ManageableState;
namespacePrefix?: string;
type: string;
};
/**
* Raw response returned from a checkRetrieveStatus call to the Metadata API
*/
export type MetadataApiRetrieveStatus = {
done: boolean;
fileProperties: FileProperties | FileProperties[];
id: string;
status: RequestStatus;
success: boolean;
messages?: RetrieveMessage[] | RetrieveMessage;
/** `base64` encoded string */
zipFile: string;
};
// ------------------------------------------------
// Client options
// ------------------------------------------------
export type PackageOption = {
/**
* The name of the package to retrieve.
*/
name: string;
/**
* The directory where the retrieved package source should be
* converted. If this is not specified the directory will
* default to `<process.cwd()>/PackageOption.name`.
*/
outputDir?: SourcePath;
};
export type PackageOptions = string[] | PackageOption[];
export type RetrieveExtractOptions = {
/**
* Top most directory within the retrieved zip file.
* E.g., `unpackaged` for unpackaged source, or the name of the
* package for retrieved package source.
*/
zipTreeLocation: string;
/**
* The directory where the retrieved source should be converted.
* This is `RetrieveOptions.output` for unpackaged source, and
* `PackageOption.outputDir` for packaged source.
*/
outputDir: SourcePath;
};
export type RetrieveOptions = {
/**
* The directory to retrieve components to. If `merge: true`, components are only
* retrieved to `output` if there wasn't a component to merge with.
*/
output: SourcePath;
/**
* Whether or not to merge and replace input components with the retrieved versions.
*/
merge?: boolean;
/**
* A list of package names to retrieve, or package names and their retrieval locations.
*/
packageOptions?: PackageOptions;
/**
* The file format desired for the retrieved files.
*/
format?: SfdxFileFormat;
/**
* Specifies whether only a single package is being retrieved (true) or not (false).
* If false, then more than one package is being retrieved.
*/
singlePackage?: boolean;
/**
* The name of the retrieved zip file containing the source from the org. Only applies when `format: metadata`.
*/
zipFileName?: string;
/**
* Specifies whether to unzip the retrieved zip file. Only applies when `format: metadata`.
*/
unzip?: boolean;
/**
* Specifies whether to suppress the <Pre|Post><Retrieve> events
*/
suppressEvents?: boolean;
};
export type MetadataApiDeployOptions = {
allowMissingFiles?: boolean;
autoUpdatePackage?: boolean;
checkOnly?: boolean;
ignoreWarnings?: boolean;
performRetrieve?: boolean;
purgeOnDelete?: boolean;
rollbackOnError?: boolean;
runAllTests?: boolean;
runTests?: string[];
singlePackage?: boolean;
testLevel?: 'NoTestRun' | 'RunSpecifiedTests' | 'RunLocalTests' | 'RunAllTestsInOrg';
/**
* Set to true to use the REST API for deploying.
*/
rest?: boolean;
};
export type StdValueSetRecord = {
Id: string;
MasterLabel: string;
Metadata: { standardValue: Array<Record<string, unknown>> };
};
export type ListMetadataQuery = {
type: string;
folder?: string;
};
export type DeployVersionData = {
apiVersion: string;
manifestVersion: string | undefined;
webService: 'SOAP' | 'REST';
};
/**
* Data about a deployment zip file being sent to the Metadata API.
*/
export type DeployZipData = {
zipSize: number;
zipFileCount: number;
};
export type RetrieveVersionData = {
apiVersion: string;
manifestVersion: string;
};
export type MetadataApiRetrieveOptions = MetadataTransferOptions & RetrieveOptions & { registry?: RegistryAccess };