@salesforce/plugin-data 3.7.1 → 3.8.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.
@@ -0,0 +1,97 @@
1
+ /*
2
+ * Copyright (c) 2024, salesforce.com, inc.
3
+ * All rights reserved.
4
+ * Licensed under the BSD 3-Clause license.
5
+ * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6
+ */
7
+ import { MultiStageOutput } from '@oclif/multi-stage-output';
8
+ import terminalLink from 'terminal-link';
9
+ export class BulkImportStages {
10
+ mso;
11
+ resume;
12
+ constructor({ resume, title, baseUrl, jsonEnabled }) {
13
+ this.resume = resume;
14
+ this.mso = new MultiStageOutput({
15
+ title,
16
+ jsonEnabled,
17
+ stages: ['Creating ingest job', 'Processing the job'],
18
+ stageSpecificBlock: [
19
+ {
20
+ stage: 'Processing the job',
21
+ label: 'Processed records',
22
+ type: 'dynamic-key-value',
23
+ get: (data) => {
24
+ if (data?.numberRecordsProcessed) {
25
+ return data.numberRecordsProcessed.toString();
26
+ }
27
+ },
28
+ },
29
+ {
30
+ stage: 'Processing the job',
31
+ label: 'Successful records',
32
+ type: 'dynamic-key-value',
33
+ get: (data) => {
34
+ const numberRecordsFailed = data?.numberRecordsFailed ?? 0;
35
+ if (data?.numberRecordsProcessed) {
36
+ return (data.numberRecordsProcessed - numberRecordsFailed).toString();
37
+ }
38
+ },
39
+ },
40
+ {
41
+ stage: 'Processing the job',
42
+ label: 'Failed records',
43
+ type: 'dynamic-key-value',
44
+ get: (data) => {
45
+ const numberRecordsFailed = data?.numberRecordsFailed ?? 0;
46
+ if (data?.numberRecordsProcessed) {
47
+ return numberRecordsFailed.toString();
48
+ }
49
+ },
50
+ },
51
+ ],
52
+ postStagesBlock: [
53
+ {
54
+ label: 'Status',
55
+ type: 'dynamic-key-value',
56
+ bold: true,
57
+ get: (data) => data?.state,
58
+ },
59
+ {
60
+ label: 'Job Id',
61
+ type: 'dynamic-key-value',
62
+ bold: true,
63
+ get: (data) => data?.id &&
64
+ terminalLink(data.id, `${baseUrl}/lightning/setup/AsyncApiJobStatus/page?address=${encodeURIComponent(`/${data.id}`)}`, {
65
+ fallback: (text, url) => `${text} (${url})`,
66
+ }),
67
+ },
68
+ ],
69
+ });
70
+ }
71
+ start() {
72
+ if (this.resume) {
73
+ this.mso.skipTo('Processing the job');
74
+ }
75
+ else {
76
+ this.mso.goto('Creating ingest job');
77
+ }
78
+ }
79
+ processingJob() {
80
+ this.mso.goto('Processing the job');
81
+ }
82
+ setupJobListeners(job) {
83
+ job.on('inProgress', (res) => {
84
+ this.mso.updateData(res);
85
+ });
86
+ }
87
+ update(data) {
88
+ this.mso.updateData(data);
89
+ }
90
+ stop() {
91
+ this.mso.stop();
92
+ }
93
+ error() {
94
+ this.mso.error();
95
+ }
96
+ }
97
+ //# sourceMappingURL=bulkImportStages.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bulkImportStages.js","sourceRoot":"","sources":["../../src/ux/bulkImportStages.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAG7D,OAAO,YAAY,MAAM,eAAe,CAAC;AASzC,MAAM,OAAO,gBAAgB;IACnB,GAAG,CAA8B;IACjC,MAAM,CAAU;IAExB,YAAmB,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,WAAW,EAAW;QACjE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,GAAG,GAAG,IAAI,gBAAgB,CAAY;YACzC,KAAK;YACL,WAAW;YACX,MAAM,EAAE,CAAC,qBAAqB,EAAE,oBAAoB,CAAC;YACrD,kBAAkB,EAAE;gBAClB;oBACE,KAAK,EAAE,oBAAoB;oBAC3B,KAAK,EAAE,mBAAmB;oBAC1B,IAAI,EAAE,mBAAmB;oBACzB,GAAG,EAAE,CAAC,IAAI,EAAsB,EAAE;wBAChC,IAA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CAAC,EAAE,EAAE,CAAC,EAAE,EAChG;4BACE,QAAQ,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,IAAI,KAAK,GAAG,GAAG;yBAC5C,CACF;iBACJ;aACF;SACF,CAAC,CAAC;IACL,CAAC;IAEM,KAAK;QACV,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC;QACxC,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;QACvC,CAAC;IACH,CAAC;IAEM,aAAa;QAClB,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;IACtC,CAAC;IAEM,iBAAiB,CAAC,GAAwB;QAC/C,GAAG,CAAC,EAAE,CAAC,YAAY,EAAE,CAAC,GAAc,EAAE,EAAE;YACtC,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;QAC3B,CAAC,CAAC,CAAC;IACL,CAAC;IAEM,MAAM,CAAC,IAAe;QAC3B,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;IAEM,IAAI;QACT,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;IAClB,CAAC;IAEM,KAAK;QACV,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC;IACnB,CAAC;CACF"}
@@ -0,0 +1,79 @@
1
+ # summary
2
+
3
+ Bulk import records into a Salesforce object from a CSV file. Uses Bulk API 2.0.
4
+
5
+ # description
6
+
7
+ You can use this command to import millions of records into the object from a file in comma-separated values (CSV) format.
8
+
9
+ All the records in the CSV file must be for the same Salesforce object. Specify the object with the `--sobject` flag.
10
+
11
+ Bulk imports can take a while, depending on how many records are in the CSV file. If the command times out, or you specified the --async flag, the command displays the job ID. To see the status and get the results of the job, run "sf data import resume" and pass the job ID to the --job-id flag.
12
+
13
+ For information and examples about how to prepare your CSV files, see "Prepare Data to Ingest" in the "Bulk API 2.0 and Bulk API Developer Guide" (https://developer.salesforce.com/docs/atlas.en-us.api_asynch.meta/api_asynch/datafiles_prepare_data.htm).
14
+
15
+ # examples
16
+
17
+ - Import Account records from a CSV-formatted file into an org with alias "my-scratch"; if the import doesn't complete in 10 minutes, the command ends and displays a job ID:
18
+
19
+ <%= config.bin %> <%= command.id %> --file accounts.csv --sobject Account --wait 10 --target-org my-scratch
20
+
21
+ - Import asynchronously and use the default org; the command immediately returns a job ID that you then pass to the "sf data import resume" command:
22
+
23
+ <%= config.bin %> <%= command.id %> --file accounts.csv --sobject Account --async
24
+
25
+ # flags.async.summary
26
+
27
+ Don't wait for the command to complete.
28
+
29
+ # flags.file.summary
30
+
31
+ CSV file that contains the Salesforce object records you want to import.
32
+
33
+ # flags.sobject.summary
34
+
35
+ API name of the Salesforce object, either standard or custom, into which you're importing records.
36
+
37
+ # flags.wait.summary
38
+
39
+ Time to wait for the command to finish, in minutes.
40
+
41
+ # flags.line-ending.summary
42
+
43
+ Line ending used in the CSV file. Default value on Windows is `CRLF`; on macOS and Linux it's `LR`.
44
+
45
+ # export.resume
46
+
47
+ Run "sf data import resume --job-id %s" to resume the operation.
48
+
49
+ # error.timeout
50
+
51
+ The operation timed out after %s minutes.
52
+
53
+ Run "sf data import resume --job-id %s" to resume it.
54
+
55
+ # error.failedRecordDetails
56
+
57
+ Job finished being processed but failed to import %s records.
58
+
59
+ To review the details of this job, run this command:
60
+
61
+ sf org open --target-org %s --path "/lightning/setup/AsyncApiJobStatus/page?address=%2F%s"
62
+
63
+ # error.jobFailed
64
+
65
+ Job failed to be processed due to:
66
+
67
+ %s
68
+
69
+ To review the details of this job, run this command:
70
+
71
+ sf org open --target-org %s --path "/lightning/setup/AsyncApiJobStatus/page?address=%2F%s"
72
+
73
+ # error.jobAborted
74
+
75
+ Job has been aborted.
76
+
77
+ To review the details of this job, run this command:
78
+
79
+ sf org open --target-org %s --path "/lightning/setup/AsyncApiJobStatus/page?address=%2F%s"
@@ -0,0 +1,61 @@
1
+ # summary
2
+
3
+ Resume a bulk import job that you previously started. Uses Bulk API 2.0.
4
+
5
+ # description
6
+
7
+ When the original "sf data import bulk" command either times out or is run with the --async flag, it displays a job ID. To see the status and get the results of the bulk import, run this command by either passing it the job ID or using the --use-most-recent flag to specify the most recent bulk import job.
8
+
9
+ # examples
10
+
11
+ - Resume a bulk import job to your default org using an ID:
12
+
13
+ <%= config.bin %> <%= command.id %> --job-id 750xx000000005sAAA
14
+
15
+ - Resume the most recently run bulk import job for an org with alias my-scratch:
16
+
17
+ <%= config.bin %> <%= command.id %> --use-most-recent --target-org my-scratch
18
+
19
+ # flags.use-most-recent.summary
20
+
21
+ Use the job ID of the bulk import job that was most recently run.
22
+
23
+ # flags.job-id.summary
24
+
25
+ Job ID of the bulk import.
26
+
27
+ # flags.wait.summary
28
+
29
+ Time to wait for the command to finish, in minutes.
30
+
31
+ # error.failedRecordDetails
32
+
33
+ Job finished being processed but failed to import %s records.
34
+
35
+ To review the details of this job, run this command:
36
+
37
+ sf org open --target-org %s --path "/lightning/setup/AsyncApiJobStatus/page?address=%2F%s"
38
+
39
+ # error.timeout
40
+
41
+ The operation timed out after %s minutes.
42
+
43
+ Try re-running "sf data import resume --job-id %s" with a bigger wait time.
44
+
45
+ # error.jobFailed
46
+
47
+ Job failed to be processed due to:
48
+
49
+ %s
50
+
51
+ To review the details of this job, run this command:
52
+
53
+ sf org open --target-org %s --path "/lightning/setup/AsyncApiJobStatus/page?address=%2F%s"
54
+
55
+ # error.jobAborted
56
+
57
+ Job has been aborted.
58
+
59
+ To review the details of this job, run this command:
60
+
61
+ sf org open --target-org %s --path "/lightning/setup/AsyncApiJobStatus/page?address=%2F%s"
@@ -54,7 +54,7 @@ The bulk request id must be supplied when not looking for most recent cache entr
54
54
 
55
55
  # error.bulkRequestIdNotFound
56
56
 
57
- Could not find a cache entry for job ID %s
57
+ Could not find a cache entry for job ID %s.
58
58
 
59
59
  # error.missingCacheEntryError
60
60