@salesforce/plugin-data-seeding 1.1.3
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/LICENSE.txt +12 -0
- package/README.md +294 -0
- package/lib/commands/data-seeding/generate/index.d.ts +16 -0
- package/lib/commands/data-seeding/generate/index.js +146 -0
- package/lib/commands/data-seeding/generate/index.js.map +1 -0
- package/lib/commands/data-seeding/generate/report.d.ts +12 -0
- package/lib/commands/data-seeding/generate/report.js +70 -0
- package/lib/commands/data-seeding/generate/report.js.map +1 -0
- package/lib/commands/data-seeding/migrate/index.d.ts +16 -0
- package/lib/commands/data-seeding/migrate/index.js +146 -0
- package/lib/commands/data-seeding/migrate/index.js.map +1 -0
- package/lib/commands/data-seeding/migrate/report.d.ts +12 -0
- package/lib/commands/data-seeding/migrate/report.js +68 -0
- package/lib/commands/data-seeding/migrate/report.js.map +1 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +8 -0
- package/lib/index.js.map +1 -0
- package/lib/utils/api.d.ts +22 -0
- package/lib/utils/api.js +84 -0
- package/lib/utils/api.js.map +1 -0
- package/lib/utils/cache.d.ts +20 -0
- package/lib/utils/cache.js +65 -0
- package/lib/utils/cache.js.map +1 -0
- package/lib/utils/mso.d.ts +15 -0
- package/lib/utils/mso.js +112 -0
- package/lib/utils/mso.js.map +1 -0
- package/lib/utils/types.d.ts +16 -0
- package/lib/utils/types.js +8 -0
- package/lib/utils/types.js.map +1 -0
- package/messages/data-seeding.generate.md +47 -0
- package/messages/data-seeding.generate.report.md +25 -0
- package/messages/data-seeding.migrate.md +47 -0
- package/messages/data-seeding.migrate.report.md +25 -0
- package/npm-shrinkwrap.json +14467 -0
- package/oclif.lock +7962 -0
- package/oclif.manifest.json +337 -0
- package/package.json +216 -0
- package/schemas/data__seeding-generate-report.json +32 -0
- package/schemas/data__seeding-generate.json +38 -0
- package/schemas/data__seeding-migrate-report.json +32 -0
- package/schemas/data__seeding-migrate.json +38 -0
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Copyright (c) 2024, Salesforce.com, Inc.
|
|
2
|
+
All rights reserved.
|
|
3
|
+
|
|
4
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
5
|
+
|
|
6
|
+
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
7
|
+
|
|
8
|
+
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
9
|
+
|
|
10
|
+
* Neither the name of Salesforce.com nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
|
11
|
+
|
|
12
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/README.md
ADDED
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
**NOTE: This template for sf plugins is not yet official. Please consult with the Platform CLI team before using this template.**
|
|
2
|
+
|
|
3
|
+
# plugin-data-seeding
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@salesforce/plugin-data-seeding) [](https://npmjs.org/package/@salesforce/plugin-data-seeding) [](https://raw.githubusercontent.com/salesforcecli/plugin-data-seeding/main/LICENSE.txt)
|
|
6
|
+
|
|
7
|
+
## Using the template
|
|
8
|
+
|
|
9
|
+
This repository provides a template for creating a plugin for the Salesforce CLI. To convert this template to a working plugin:
|
|
10
|
+
|
|
11
|
+
1. Please get in touch with the Platform CLI team. We want to help you develop your plugin.
|
|
12
|
+
2. Generate your plugin:
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
sf plugins install dev
|
|
16
|
+
sf dev generate plugin
|
|
17
|
+
|
|
18
|
+
git init -b main
|
|
19
|
+
git add . && git commit -m "chore: initial commit"
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
3. Create your plugin's repo in the salesforcecli github org
|
|
23
|
+
4. When you're ready, replace the contents of this README with the information you want.
|
|
24
|
+
|
|
25
|
+
## Learn about `sf` plugins
|
|
26
|
+
|
|
27
|
+
Salesforce CLI plugins are based on the [oclif plugin framework](https://oclif.io/docs/introduction). Read the [plugin developer guide](https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_plugins.meta/sfdx_cli_plugins/cli_plugins_architecture_sf_cli.htm) to learn about Salesforce CLI plugin development.
|
|
28
|
+
|
|
29
|
+
This repository contains a lot of additional scripts and tools to help with general Salesforce node development and enforce coding standards. You should familiarize yourself with some of the [node developer packages](#tooling) used by Salesforce. There is also a default circleci config using the [release management orb](https://github.com/forcedotcom/npm-release-management-orb) standards.
|
|
30
|
+
|
|
31
|
+
Additionally, there are some additional tests that the Salesforce CLI will enforce if this plugin is ever bundled with the CLI. These test are included by default under the `posttest` script and it is required to keep these tests active in your plugin if you plan to have it bundled.
|
|
32
|
+
|
|
33
|
+
### Tooling
|
|
34
|
+
|
|
35
|
+
- [@salesforce/core](https://github.com/forcedotcom/sfdx-core)
|
|
36
|
+
- [@salesforce/kit](https://github.com/forcedotcom/kit)
|
|
37
|
+
- [@salesforce/sf-plugins-core](https://github.com/salesforcecli/sf-plugins-core)
|
|
38
|
+
- [@salesforce/ts-types](https://github.com/forcedotcom/ts-types)
|
|
39
|
+
- [@salesforce/ts-sinon](https://github.com/forcedotcom/ts-sinon)
|
|
40
|
+
- [@salesforce/dev-config](https://github.com/forcedotcom/dev-config)
|
|
41
|
+
- [@salesforce/dev-scripts](https://github.com/forcedotcom/dev-scripts)
|
|
42
|
+
|
|
43
|
+
# Everything past here is only a suggestion as to what should be in your specific plugin's description
|
|
44
|
+
|
|
45
|
+
This plugin is bundled with the [Salesforce CLI](https://developer.salesforce.com/tools/sfdxcli). For more information on the CLI, read the [getting started guide](https://developer.salesforce.com/docs/atlas.en-us.sfdx_setup.meta/sfdx_setup/sfdx_setup_intro.htm).
|
|
46
|
+
|
|
47
|
+
We always recommend using the latest version of these commands bundled with the CLI, however, you can install a specific version or tag if needed.
|
|
48
|
+
|
|
49
|
+
## Install
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
sf plugins install @salesforce/plugin-data-seeding@x.y.z
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Issues
|
|
56
|
+
|
|
57
|
+
Please report any issues at https://github.com/forcedotcom/cli/issues
|
|
58
|
+
|
|
59
|
+
## Contributing
|
|
60
|
+
|
|
61
|
+
1. Please read our [Code of Conduct](CODE_OF_CONDUCT.md)
|
|
62
|
+
2. Create a new issue before starting your project so that we can keep track of
|
|
63
|
+
what you are trying to add/fix. That way, we can also offer suggestions or
|
|
64
|
+
let you know if there is already an effort in progress.
|
|
65
|
+
3. Fork this repository.
|
|
66
|
+
4. [Build the plugin locally](#build)
|
|
67
|
+
5. Create a _topic_ branch in your fork. Note, this step is recommended but technically not required if contributing using a fork.
|
|
68
|
+
6. Edit the code in your fork.
|
|
69
|
+
7. Write appropriate tests for your changes. Try to achieve at least 95% code coverage on any new code. No pull request will be accepted without unit tests.
|
|
70
|
+
8. Sign CLA (see [CLA](#cla) below).
|
|
71
|
+
9. Send us a pull request when you are done. We'll review your code, suggest any needed changes, and merge it in.
|
|
72
|
+
|
|
73
|
+
### CLA
|
|
74
|
+
|
|
75
|
+
External contributors will be required to sign a Contributor's License
|
|
76
|
+
Agreement. You can do so by going to https://cla.salesforce.com/sign-cla.
|
|
77
|
+
|
|
78
|
+
### Build
|
|
79
|
+
|
|
80
|
+
To build the plugin locally, make sure to have yarn installed and run the following commands:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
# Clone the repository
|
|
84
|
+
git clone git@github.com:salesforcecli/plugin-data-seeding
|
|
85
|
+
|
|
86
|
+
# Install the dependencies and compile
|
|
87
|
+
yarn && yarn build
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
To use your plugin, run using the local `./bin/dev.js` or `./bin/dev.cmd` file.
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
# Run using local run file.
|
|
94
|
+
./bin/dev.js data-seeding generate
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
There should be no differences when running via the Salesforce CLI or using the local run file. However, it can be useful to link the plugin to do some additional testing or run your commands from anywhere on your machine.
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
# Link your plugin to the sf cli
|
|
101
|
+
sf plugins link .
|
|
102
|
+
# To verify
|
|
103
|
+
sf plugins
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Commands
|
|
107
|
+
|
|
108
|
+
<!-- commands -->
|
|
109
|
+
|
|
110
|
+
- [`sf data-seeding generate`](#sf-data-seeding-generate)
|
|
111
|
+
- [`sf data-seeding generate report`](#sf-data-seeding-generate-report)
|
|
112
|
+
- [`sf data-seeding migrate`](#sf-data-seeding-migrate)
|
|
113
|
+
- [`sf data-seeding migrate report`](#sf-data-seeding-migrate-report)
|
|
114
|
+
|
|
115
|
+
## `sf data-seeding generate`
|
|
116
|
+
|
|
117
|
+
Generate synthetic org data that mimics existing data in a source org, and then load it into a separate target org.
|
|
118
|
+
|
|
119
|
+
```
|
|
120
|
+
USAGE
|
|
121
|
+
$ sf data-seeding generate -o <value> -s <value> -f <value> [--json] [--flags-dir <value>] [-w <value> | --async]
|
|
122
|
+
|
|
123
|
+
FLAGS
|
|
124
|
+
-f, --config-file=<value> (required) Path to the data seeding JSON configuration file.
|
|
125
|
+
-o, --target-org=<value> (required) Username or alias of the target org into which the generated data will be
|
|
126
|
+
loaded.
|
|
127
|
+
-s, --source-org=<value> (required) Username or alias of the source org that contains the data that AI will mimic.
|
|
128
|
+
-w, --wait=<value> [default: 33 minutes] Number of minutes to wait for the command to complete; when reached,
|
|
129
|
+
the command completes asynchronously if necessary.
|
|
130
|
+
--async Run the command asynchronously and immediately return control of the terminal.
|
|
131
|
+
|
|
132
|
+
GLOBAL FLAGS
|
|
133
|
+
--flags-dir=<value> Import flag values from a directory.
|
|
134
|
+
--json Format output as json.
|
|
135
|
+
|
|
136
|
+
DESCRIPTION
|
|
137
|
+
Generate synthetic org data that mimics existing data in a source org, and then load it into a separate target org.
|
|
138
|
+
|
|
139
|
+
This command uses AI to generate synthetic (or "fake") data that has a similar format to selected data in a source
|
|
140
|
+
org. The command uses a JSON configuration file to define the characteristics of the synthetic data. For example, the
|
|
141
|
+
configuration file might specify the number of records to generate for one or more Salesforce objects, along with the
|
|
142
|
+
subset of fields to include. Once generated, the data is automatically loaded into the specified target org. You must
|
|
143
|
+
be authenticated to both the source and target orgs before running this command.
|
|
144
|
+
|
|
145
|
+
By default, this command runs synchronously and outputs the job ID, along with a running status of each execution
|
|
146
|
+
phase, such as querying the source org or generating the data. If you prefer, you can run the command asynchronously
|
|
147
|
+
by specifying the --async flag so that the control of the terminal is immediately returned to you. Then use the job ID
|
|
148
|
+
to run the "data-seeding generate report" command to view the status.
|
|
149
|
+
|
|
150
|
+
EXAMPLES
|
|
151
|
+
Generate synthetic data similar to existing data in the org with alias "mySourceOrg" then load it into the org with
|
|
152
|
+
alias "myTargetOrg"; use the specified config file to determine the format of the generated data:
|
|
153
|
+
|
|
154
|
+
$ sf data-seeding generate --source-org mySourceOrg --target-org myTargetOrg --config-file \
|
|
155
|
+
./config/seed-config.json
|
|
156
|
+
|
|
157
|
+
Generate synthetic data using org usernames and run the command asynchronously:
|
|
158
|
+
|
|
159
|
+
$ sf data-seeding generate --source-org source@org.com" --target-org target@org.com" --config-file \
|
|
160
|
+
./config/seed-config.json --async
|
|
161
|
+
|
|
162
|
+
Generate synthetic data using org aliases; if after 5 minutes the command hasn't finished, it completes
|
|
163
|
+
asynchronously:
|
|
164
|
+
|
|
165
|
+
$ sf data-seeding generate --source-org source@org.com" --target-org target@org.com" --config-file \
|
|
166
|
+
./config/seed-config.json --wait 5
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
_See code: [src/commands/data-seeding/generate/index.ts](https://github.com/salesforcecli/plugin-data-seeding/blob/1.1.3/src/commands/data-seeding/generate/index.ts)_
|
|
170
|
+
|
|
171
|
+
## `sf data-seeding generate report`
|
|
172
|
+
|
|
173
|
+
Display the status of a data-seeding generate job.
|
|
174
|
+
|
|
175
|
+
```
|
|
176
|
+
USAGE
|
|
177
|
+
$ sf data-seeding generate report [--json] [--flags-dir <value>] [-i <value>] [-r]
|
|
178
|
+
|
|
179
|
+
FLAGS
|
|
180
|
+
-i, --job-id=<value> ID of a specific execution of the "data-seeding generate" command.
|
|
181
|
+
-r, --use-most-recent View the status of the most recently run "data-seeding generate" command.
|
|
182
|
+
|
|
183
|
+
GLOBAL FLAGS
|
|
184
|
+
--flags-dir=<value> Import flag values from a directory.
|
|
185
|
+
--json Format output as json.
|
|
186
|
+
|
|
187
|
+
DESCRIPTION
|
|
188
|
+
Display the status of a data-seeding generate job.
|
|
189
|
+
|
|
190
|
+
This command displays the status of a previously initiated or completed execution of the "data-seeding generate"
|
|
191
|
+
command. Run this command by either passing it the job ID returned by "data-seeding generate", or use the
|
|
192
|
+
--use-most-recent flag to view the status of the most recently run "data-seeding generate" command.
|
|
193
|
+
|
|
194
|
+
EXAMPLES
|
|
195
|
+
Display the status of a specific execution of the "data-seeding generate" command:
|
|
196
|
+
|
|
197
|
+
$ sf data-seeding generate report --job-id 1234-5678-AAAA-BBBB
|
|
198
|
+
|
|
199
|
+
Display the status of the most recently run "data-seeding generate" command:
|
|
200
|
+
|
|
201
|
+
$ sf data-seeding generate report --use-most-recent
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
_See code: [src/commands/data-seeding/generate/report.ts](https://github.com/salesforcecli/plugin-data-seeding/blob/1.1.3/src/commands/data-seeding/generate/report.ts)_
|
|
205
|
+
|
|
206
|
+
## `sf data-seeding migrate`
|
|
207
|
+
|
|
208
|
+
Migrate data from one org to another.
|
|
209
|
+
|
|
210
|
+
```
|
|
211
|
+
USAGE
|
|
212
|
+
$ sf data-seeding migrate -o <value> -s <value> -f <value> [--json] [--flags-dir <value>] [-w <value> | --async]
|
|
213
|
+
|
|
214
|
+
FLAGS
|
|
215
|
+
-f, --config-file=<value> (required) Path to the data migration JSON configuration file.
|
|
216
|
+
-o, --target-org=<value> (required) Username or alias of the target org into which the migrated data is loaded.
|
|
217
|
+
-s, --source-org=<value> (required) Username or alias of the source org that contains the data to be migrated.
|
|
218
|
+
-w, --wait=<value> [default: 33 minutes] Number of minutes to wait for the command to complete; when reached,
|
|
219
|
+
the command completes asynchronously if necessary.
|
|
220
|
+
--async Run the command asynchronously and immediately return control of the terminal.
|
|
221
|
+
|
|
222
|
+
GLOBAL FLAGS
|
|
223
|
+
--flags-dir=<value> Import flag values from a directory.
|
|
224
|
+
--json Format output as json.
|
|
225
|
+
|
|
226
|
+
DESCRIPTION
|
|
227
|
+
Migrate data from one org to another.
|
|
228
|
+
|
|
229
|
+
This command migrates selected data from a source org and loads it into a target org. The command uses a JSON
|
|
230
|
+
configuration file that defines the characteristics of the data. For example, the configuration file might specify a
|
|
231
|
+
number of records from one or more Salesforce objects to migrate, along with the subset of fields to include. You must
|
|
232
|
+
be authenticated to both the source and target orgs before running this command.
|
|
233
|
+
|
|
234
|
+
By default, this command runs synchronously and outputs a job ID along with a running status of each execution phase,
|
|
235
|
+
such as querying the source org or loading into the target. If you prefer, you can run the command asynchronously by
|
|
236
|
+
specifying the --async flag so that the control of the terminal is immediately returned to you. Then use the job ID to
|
|
237
|
+
run the "data-seeding migrate report" command to view the status.
|
|
238
|
+
|
|
239
|
+
EXAMPLES
|
|
240
|
+
Migrate data from the org with alias "mySourceOrg" to the org with alias "myTargetOrg"; use the specified
|
|
241
|
+
configuration file to determine the data to migrate:
|
|
242
|
+
|
|
243
|
+
$ sf data-seeding migrate --source-org mySourceOrg --target-org myTargetOrg --config-file \
|
|
244
|
+
./config/data-seed.json
|
|
245
|
+
|
|
246
|
+
Migrate data by specifying usernames for the source and target orgs, and run the command asynchronously:
|
|
247
|
+
|
|
248
|
+
$ sf data-seeding migrate --source-org source@org.com --target-org target@org.com \
|
|
249
|
+
--config-file=./config/data-seed.json --async
|
|
250
|
+
|
|
251
|
+
Migrate data using org aliases; if after 5 minutes the command hasn't finished, it completes asynchronously:
|
|
252
|
+
|
|
253
|
+
$ sf data-seeding migrate --source-org mySourceOrg --target-org myTargetOrg --config-file \
|
|
254
|
+
./config/data-seed.json --wait 5
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
_See code: [src/commands/data-seeding/migrate/index.ts](https://github.com/salesforcecli/plugin-data-seeding/blob/1.1.3/src/commands/data-seeding/migrate/index.ts)_
|
|
258
|
+
|
|
259
|
+
## `sf data-seeding migrate report`
|
|
260
|
+
|
|
261
|
+
Display the status of a data-seeding migrate job.
|
|
262
|
+
|
|
263
|
+
```
|
|
264
|
+
USAGE
|
|
265
|
+
$ sf data-seeding migrate report [--json] [--flags-dir <value>] [-i <value>] [-r]
|
|
266
|
+
|
|
267
|
+
FLAGS
|
|
268
|
+
-i, --job-id=<value> ID of a specific execution of the "data-seeding migrate" command.
|
|
269
|
+
-r, --use-most-recent View the status of the most recently run "data-seeding migrate" command.
|
|
270
|
+
|
|
271
|
+
GLOBAL FLAGS
|
|
272
|
+
--flags-dir=<value> Import flag values from a directory.
|
|
273
|
+
--json Format output as json.
|
|
274
|
+
|
|
275
|
+
DESCRIPTION
|
|
276
|
+
Display the status of a data-seeding migrate job.
|
|
277
|
+
|
|
278
|
+
This command displays the status of a previously initiated or completed execution of the "data-seeding migrate"
|
|
279
|
+
command. Run this command by either passing it the job ID returned by "data-seeding migrate", or use the
|
|
280
|
+
--use-most-recent flag to view the status of the most recently run "data-seeding migrate" command.
|
|
281
|
+
|
|
282
|
+
EXAMPLES
|
|
283
|
+
Display the status of a specific execution of the "data-seeding migrate" command:
|
|
284
|
+
|
|
285
|
+
$ sf data-seeding migrate report --job-id 1234-5678-AAAA-BBBB
|
|
286
|
+
|
|
287
|
+
Display the status of the most recently run "data-seeding migrate" command:
|
|
288
|
+
|
|
289
|
+
$ sf data-seeding migrate report --use-most-recent
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
_See code: [src/commands/data-seeding/migrate/report.ts](https://github.com/salesforcecli/plugin-data-seeding/blob/1.1.3/src/commands/data-seeding/migrate/report.ts)_
|
|
293
|
+
|
|
294
|
+
<!-- commandsstop -->
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { SfCommand } from '@salesforce/sf-plugins-core';
|
|
2
|
+
import { Duration } from '@salesforce/kit';
|
|
3
|
+
import { DataSeedingGenerateResult } from '../../../utils/types.js';
|
|
4
|
+
export default class DataSeedingGenerate extends SfCommand<DataSeedingGenerateResult> {
|
|
5
|
+
static readonly summary: string;
|
|
6
|
+
static readonly description: string;
|
|
7
|
+
static readonly examples: string[];
|
|
8
|
+
static readonly flags: {
|
|
9
|
+
'target-org': import("@oclif/core/interfaces").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
'source-org': import("@oclif/core/interfaces").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
+
'config-file': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
+
wait: import("@oclif/core/interfaces").OptionFlag<Duration, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
+
async: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
14
|
+
};
|
|
15
|
+
run(): Promise<DataSeedingGenerateResult>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023, 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 { SfCommand, Flags } from '@salesforce/sf-plugins-core';
|
|
8
|
+
import { Messages, PollingClient, SfError } from '@salesforce/core';
|
|
9
|
+
import { Duration } from '@salesforce/kit';
|
|
10
|
+
import { initiateDataSeed, pollSeedStatus, initiateJWTMint } from '../../../utils/api.js';
|
|
11
|
+
import { getSeedGenerateMso, getSeedGenerateStage as getStage } from '../../../utils/mso.js';
|
|
12
|
+
import { GenerateRequestCache } from '../../../utils/cache.js';
|
|
13
|
+
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
14
|
+
const messages = Messages.loadMessages('@salesforce/plugin-data-seeding', 'data-seeding.generate');
|
|
15
|
+
export default class DataSeedingGenerate extends SfCommand {
|
|
16
|
+
static summary = messages.getMessage('summary');
|
|
17
|
+
static description = messages.getMessage('description');
|
|
18
|
+
static examples = messages.getMessages('examples');
|
|
19
|
+
static flags = {
|
|
20
|
+
// TODO: The org flags will need to use Flags.requiredOrg() once auth is finalized
|
|
21
|
+
'target-org': Flags.requiredOrg({
|
|
22
|
+
summary: messages.getMessage('flags.target-org.summary'),
|
|
23
|
+
char: 'o',
|
|
24
|
+
required: true,
|
|
25
|
+
}),
|
|
26
|
+
'source-org': Flags.requiredOrg({
|
|
27
|
+
summary: messages.getMessage('flags.source-org.summary'),
|
|
28
|
+
char: 's',
|
|
29
|
+
required: true,
|
|
30
|
+
}),
|
|
31
|
+
'config-file': Flags.file({
|
|
32
|
+
summary: messages.getMessage('flags.config-file.summary'),
|
|
33
|
+
char: 'f',
|
|
34
|
+
required: true,
|
|
35
|
+
exists: true,
|
|
36
|
+
}),
|
|
37
|
+
wait: Flags.duration({
|
|
38
|
+
summary: messages.getMessage('flags.wait.summary'),
|
|
39
|
+
char: 'w',
|
|
40
|
+
unit: 'minutes',
|
|
41
|
+
defaultValue: 33,
|
|
42
|
+
min: 1,
|
|
43
|
+
exclusive: ['async'],
|
|
44
|
+
}),
|
|
45
|
+
async: Flags.boolean({
|
|
46
|
+
summary: messages.getMessage('flags.async.summary'),
|
|
47
|
+
exclusive: ['wait'],
|
|
48
|
+
}),
|
|
49
|
+
};
|
|
50
|
+
async run() {
|
|
51
|
+
const { flags } = await this.parse(DataSeedingGenerate);
|
|
52
|
+
const { async, 'config-file': configFile, 'source-org': srcOrgObj, 'target-org': tgtOrgObj, wait } = flags;
|
|
53
|
+
const sourceOrg = srcOrgObj.getOrgId();
|
|
54
|
+
const srcAccessToken = srcOrgObj.getConnection().accessToken;
|
|
55
|
+
const srcOrgInstUrl = srcOrgObj.getConnection().instanceUrl;
|
|
56
|
+
const targetOrg = tgtOrgObj.getOrgId();
|
|
57
|
+
const tgtAccessToken = tgtOrgObj.getConnection().accessToken;
|
|
58
|
+
const tgtOrgInstUrl = tgtOrgObj.getConnection().instanceUrl;
|
|
59
|
+
// Fetch Valid JWT with Data Seed Org Perm
|
|
60
|
+
const { jwt: jwtValue } = await initiateJWTMint(srcOrgInstUrl, srcAccessToken, tgtOrgInstUrl, tgtAccessToken);
|
|
61
|
+
const { request_id: jobId } = await initiateDataSeed(configFile, 'data-generation', jwtValue, srcOrgInstUrl, srcAccessToken, tgtOrgInstUrl, tgtAccessToken, sourceOrg);
|
|
62
|
+
const reportMessage = messages.getMessage('report.suggestion', [jobId]);
|
|
63
|
+
if (!jobId)
|
|
64
|
+
throw new Error('Failed to receive job id');
|
|
65
|
+
const baseData = { jobId, sourceOrg, targetOrg };
|
|
66
|
+
await (await GenerateRequestCache.create()).createCacheEntry(jobId);
|
|
67
|
+
const buildResponse = (response) => ({
|
|
68
|
+
dataSeedingJob: 'generate',
|
|
69
|
+
startTime: response?.execution_start_time,
|
|
70
|
+
endTime: response?.execution_end_time,
|
|
71
|
+
status: response.status,
|
|
72
|
+
...baseData,
|
|
73
|
+
});
|
|
74
|
+
if (wait && !async) {
|
|
75
|
+
const mso = getSeedGenerateMso({ jsonEnabled: this.jsonEnabled() });
|
|
76
|
+
mso.updateData(baseData);
|
|
77
|
+
const completedStatus = ['Completed', 'Partially Completed', 'Failed'];
|
|
78
|
+
const options = {
|
|
79
|
+
poll: async () => {
|
|
80
|
+
const { jwt: jwtValueNew } = await initiateJWTMint(srcOrgInstUrl, srcAccessToken, tgtOrgInstUrl, tgtAccessToken);
|
|
81
|
+
const response = await pollSeedStatus(jobId, jwtValueNew);
|
|
82
|
+
mso.goto(getStage(response.step), {
|
|
83
|
+
startTime: response.execution_start_time,
|
|
84
|
+
endTime: response.execution_end_time,
|
|
85
|
+
status: response.status,
|
|
86
|
+
});
|
|
87
|
+
return {
|
|
88
|
+
completed: completedStatus.includes(response.status),
|
|
89
|
+
payload: response,
|
|
90
|
+
};
|
|
91
|
+
},
|
|
92
|
+
frequency: Duration.seconds(1),
|
|
93
|
+
timeout: wait,
|
|
94
|
+
};
|
|
95
|
+
try {
|
|
96
|
+
const client = await PollingClient.create(options);
|
|
97
|
+
const pollResult = await client.subscribe();
|
|
98
|
+
switch (pollResult.status) {
|
|
99
|
+
case 'Completed':
|
|
100
|
+
mso.stop();
|
|
101
|
+
break;
|
|
102
|
+
case 'Failed':
|
|
103
|
+
mso.error();
|
|
104
|
+
throw new SfError(`Data seeding job failed on step: ${pollResult.step}\nLog Text: ${pollResult.log_text}`);
|
|
105
|
+
case 'Partially Completed':
|
|
106
|
+
mso.stop('warning');
|
|
107
|
+
this.log(`Process partially completed: ${pollResult.log_text}`);
|
|
108
|
+
break;
|
|
109
|
+
default:
|
|
110
|
+
mso.stop('current');
|
|
111
|
+
}
|
|
112
|
+
return buildResponse(pollResult);
|
|
113
|
+
}
|
|
114
|
+
catch (e) {
|
|
115
|
+
const err = SfError.wrap(e);
|
|
116
|
+
if (err.message.includes('The client has timed out')) {
|
|
117
|
+
mso.updateData({ status: 'Client Timeout' });
|
|
118
|
+
err.actions = [reportMessage];
|
|
119
|
+
mso.stop('current');
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
mso.error();
|
|
123
|
+
}
|
|
124
|
+
throw err;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
const { jwt: jwtValueNew } = await initiateJWTMint(srcOrgInstUrl, srcAccessToken, tgtOrgInstUrl, tgtAccessToken);
|
|
129
|
+
const response = await pollSeedStatus(jobId, jwtValueNew);
|
|
130
|
+
const mso = getSeedGenerateMso({
|
|
131
|
+
jsonEnabled: this.jsonEnabled(),
|
|
132
|
+
showElapsedTime: false,
|
|
133
|
+
showStageTime: false,
|
|
134
|
+
});
|
|
135
|
+
mso.goto(getStage(response.step), {
|
|
136
|
+
...baseData,
|
|
137
|
+
startTime: response.execution_start_time,
|
|
138
|
+
status: 'Initiated',
|
|
139
|
+
});
|
|
140
|
+
mso.stop('async');
|
|
141
|
+
this.log(reportMessage);
|
|
142
|
+
return buildResponse(response);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/commands/data-seeding/generate/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,OAAO,EAAgB,MAAM,kBAAkB,CAAC;AAClF,OAAO,EAAE,QAAQ,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,CAAC,OAAO,CAAC,QAAQ,CAAC,0BAA0B,CAAC,EAAE,CAAC;oBACrD,GAAG,CAAC,UAAU,CAAC,EAAE,MAAM,EAAE,gBAAgB,EAAE,CAAC,CAAC;oBAC7C,GAAG,CAAC,OAAO,GAAG,CAAC,aAAa,CAAC,CAAC;oBAC9B,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;gBACtB,CAAC;qBAAM,CAAC;oBACN,GAAG,CAAC,KAAK,EAAE,CAAC;gBACd,CAAC;gBAED,MAAM,GAAG,CAAC;YACZ,CAAC;QACH,CAAC;aAAM,CAAC;YACN,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,GAAG,MAAM,eAAe,CAAC,aAAa,EAAE,cAAc,EAAE,aAAa,EAAE,cAAc,CAAC,CAAC;YACjH,MAAM,QAAQ,GAAG,MAAM,cAAc,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;YAE1D,MAAM,GAAG,GAAG,kBAAkB,CAAC;gBAC7B,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE;gBAC/B,eAAe,EAAE,KAAK;gBACtB,aAAa,EAAE,KAAK;aACrB,CAAC,CAAC;YAEH,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;gBAChC,GAAG,QAAQ;gBACX,SAAS,EAAE,QAAQ,CAAC,oBAAoB;gBACxC,MAAM,EAAE,WAAW;aACpB,CAAC,CAAC;YAEH,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAClB,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;YAExB,OAAO,aAAa,CAAC,QAAQ,CAAC,CAAC;QACjC,CAAC;IACH,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { SfCommand } from '@salesforce/sf-plugins-core';
|
|
2
|
+
import { DataSeedingReportResult } from '../../../utils/types.js';
|
|
3
|
+
export default class DataSeedingGenerateReport extends SfCommand<DataSeedingReportResult> {
|
|
4
|
+
static readonly summary: string;
|
|
5
|
+
static readonly description: string;
|
|
6
|
+
static readonly examples: string[];
|
|
7
|
+
static readonly flags: {
|
|
8
|
+
'job-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
'use-most-recent': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
10
|
+
};
|
|
11
|
+
run(): Promise<DataSeedingReportResult>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023, 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 { SfCommand, Flags } from '@salesforce/sf-plugins-core';
|
|
8
|
+
import { Messages, SfError } from '@salesforce/core';
|
|
9
|
+
import { pollSeedStatus } from '../../../utils/api.js';
|
|
10
|
+
import { getSeedGenerateMso, getSeedGenerateStage as getStage } from '../../../utils/mso.js';
|
|
11
|
+
import { GenerateRequestCache } from '../../../utils/cache.js';
|
|
12
|
+
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
13
|
+
const messages = Messages.loadMessages('@salesforce/plugin-data-seeding', 'data-seeding.generate.report');
|
|
14
|
+
// TEMP failure (Querying Source Org): 9258aae5-e9b0-4c73-a340-962d299b71bd
|
|
15
|
+
// TEMP failure (Populating Target Org): 0aab5c70-069d-48f5-aa0d-157f745c5dfe
|
|
16
|
+
export default class DataSeedingGenerateReport extends SfCommand {
|
|
17
|
+
static summary = messages.getMessage('summary');
|
|
18
|
+
static description = messages.getMessage('description');
|
|
19
|
+
static examples = messages.getMessages('examples');
|
|
20
|
+
static flags = {
|
|
21
|
+
'job-id': Flags.string({
|
|
22
|
+
summary: messages.getMessage('flags.job-id.summary'),
|
|
23
|
+
char: 'i',
|
|
24
|
+
exactlyOne: ['job-id', 'use-most-recent'],
|
|
25
|
+
}),
|
|
26
|
+
'use-most-recent': Flags.boolean({
|
|
27
|
+
summary: messages.getMessage('flags.use-most-recent.summary'),
|
|
28
|
+
char: 'r',
|
|
29
|
+
exactlyOne: ['job-id', 'use-most-recent'],
|
|
30
|
+
}),
|
|
31
|
+
};
|
|
32
|
+
async run() {
|
|
33
|
+
const { flags } = await this.parse(DataSeedingGenerateReport);
|
|
34
|
+
const jobId = flags['job-id'] ?? (await GenerateRequestCache.create()).resolveFromCache().jobId;
|
|
35
|
+
if (!jobId)
|
|
36
|
+
throw new SfError('No job ID provided or found in cache');
|
|
37
|
+
const response = await pollSeedStatus(jobId, '');
|
|
38
|
+
const data = {
|
|
39
|
+
jobId,
|
|
40
|
+
startTime: response.execution_start_time,
|
|
41
|
+
endTime: response.execution_end_time,
|
|
42
|
+
status: response.status,
|
|
43
|
+
};
|
|
44
|
+
const mso = getSeedGenerateMso({
|
|
45
|
+
jsonEnabled: this.jsonEnabled(),
|
|
46
|
+
showElapsedTime: false,
|
|
47
|
+
showStageTime: false,
|
|
48
|
+
});
|
|
49
|
+
mso.goto(getStage(response.step), data);
|
|
50
|
+
switch (response.status) {
|
|
51
|
+
case 'In Progress':
|
|
52
|
+
mso.stop('current');
|
|
53
|
+
break;
|
|
54
|
+
case 'Partially Completed':
|
|
55
|
+
mso.stop('warning');
|
|
56
|
+
this.log(`Process partially completed: ${response.log_text}`);
|
|
57
|
+
break;
|
|
58
|
+
case 'Failed':
|
|
59
|
+
mso.error();
|
|
60
|
+
throw new SfError(`Failed on step: ${response.step}\nLog Text: ${response.log_text}`);
|
|
61
|
+
default:
|
|
62
|
+
mso.stop();
|
|
63
|
+
}
|
|
64
|
+
return {
|
|
65
|
+
dataSeedingJob: 'generate',
|
|
66
|
+
...data,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=report.js.map
|
|
@@ -0,0 +1 @@
|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MAAM,IAAI,OAAO,CAAC,mBAAmB,QAAQ,CAAC,IAAI,eAAe,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC;YACxF;gBACE,GAAG,CAAC,IAAI,EAAE,CAAC;QACf,CAAC;QAED,OAAO;YACL,cAAc,EAAE,UAAU;YAC1B,GAAG,IAAI;SACR,CAAC;IACJ,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { SfCommand } from '@salesforce/sf-plugins-core';
|
|
2
|
+
import { Duration } from '@salesforce/kit';
|
|
3
|
+
import { DataSeedingMigrateResult } from '../../../utils/types.js';
|
|
4
|
+
export default class DataSeedingMigrate extends SfCommand<DataSeedingMigrateResult> {
|
|
5
|
+
static readonly summary: string;
|
|
6
|
+
static readonly description: string;
|
|
7
|
+
static readonly examples: string[];
|
|
8
|
+
static readonly flags: {
|
|
9
|
+
'target-org': import("@oclif/core/interfaces").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
'source-org': import("@oclif/core/interfaces").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
+
'config-file': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
+
wait: import("@oclif/core/interfaces").OptionFlag<Duration, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
+
async: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
14
|
+
};
|
|
15
|
+
run(): Promise<DataSeedingMigrateResult>;
|
|
16
|
+
}
|