-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat!: ga new tree commands #975
Changes from 3 commits
4e342d9
179e044
c9e3356
58e9758
52d1199
ca61218
7a21c8d
5ed1ae8
7a23811
1c7013e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# summary | ||
|
||
Import data from one or more JSON files into an org. | ||
|
||
# description | ||
|
||
The JSON files that contain the data are in sObject tree format, which is a collection of nested, parent-child records with a single root record. Use the "<%= config.bin %> data export tree" command to generate these JSON files. | ||
|
||
If you used the --plan flag when exporting the data to generate a plan definition file, use the --plan flag to reference the file when you import. If you're not using a plan, use the --files flag to list the files. If you specify multiple JSON files that depend on each other in a parent-child relationship, be sure you list them in the correct order. | ||
|
||
The sObject Tree API supports requests that contain up to 200 records. For more information, see the REST API Developer Guide. (https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_composite_sobject_tree.htm) | ||
|
||
# flags.files.summary | ||
|
||
Comma-separated and in-order JSON files that contain the records, in sObject tree format, that you want to insert. | ||
|
||
# flags.plan.summary | ||
|
||
Plan definition file to insert multiple data files. | ||
|
||
# flags.content-type.summary | ||
|
||
Content type of import files if their extention is not .json. | ||
|
||
# flags.content-type.deprecation | ||
|
||
The `config-type` flag is deprecated and will be moved to a `legacy` command after July 10, 2024. It will be completely removed after Nov 10, 2024. Use the new `data tree beta import` command. | ||
|
||
# flags.config-help.summary | ||
|
||
Display schema information for the --plan configuration file to stdout; if you specify this flag, all other flags except --json are ignored. | ||
|
||
# flags.config-help.deprecation | ||
|
||
The `config-help` flag is deprecated and will be moved to a `legacy` command after July 10, 2024. It will be completely removed after Nov 10, 2024. Use the new `data tree beta import` command. | ||
|
||
# examples | ||
|
||
- Import the records contained in two JSON files into the org with alias "my-scratch": | ||
|
||
<%= config.bin %> <%= command.id %> --files Contact.json,Account.json --target-org my-scratch | ||
|
||
- Import records using a plan definition file into your default org: | ||
|
||
<%= config.bin %> <%= command.id %> --plan Account-Contact-plan.json | ||
|
||
# schema-help | ||
|
||
schema(array) - Data Import Plan: Schema for SFDX Toolbelt's data import plan JSON. | ||
|
||
- items(object) - SObject Type: Definition of records to be insert per SObject Type | ||
- sobject(string) - Name of SObject: Child file references must have SObject roots of this type | ||
- saveRefs(boolean) - Save References: Post-save, save references (Name/ID) to be used for reference replacement in subsequent saves. Applies to all data files for this SObject type. | ||
- resolveRefs(boolean) - Resolve References: Pre-save, replace @<reference> with ID from previous save. Applies to all data files for this SObject type. | ||
- files(array) - Files: An array of files paths to load | ||
- items(string|object) - Filepath: Filepath string or object to point to a JSON or XML file having data defined in SObject Tree format. | ||
|
||
# deprecation | ||
|
||
After Nov 10, 2024, this command will no longer be available. Use `data export tree`. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,8 +7,8 @@ | |
|
||
import { Messages } from '@salesforce/core'; | ||
import { SfCommand, Flags, Ux } from '@salesforce/sf-plugins-core'; | ||
import { orgFlags, prefixValidation } from '../../../../flags.js'; | ||
import { ExportConfig, runExport } from '../../../../export.js'; | ||
import { orgFlags } from '../../../../flags.js'; | ||
import { ExportApi, ExportConfig } from '../../../../api/data/tree/exportApi.js'; | ||
import type { DataPlanPart, SObjectTreeFileContents } from '../../../../types.js'; | ||
|
||
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url); | ||
|
@@ -18,9 +18,11 @@ export default class Export extends SfCommand<DataPlanPart[] | SObjectTreeFileCo | |
public static readonly summary = messages.getMessage('summary'); | ||
public static readonly description = messages.getMessage('description'); | ||
public static readonly examples = messages.getMessages('examples'); | ||
// TODO: when you remove the beta state, put the force: aliases back in | ||
public static readonly state = 'beta'; | ||
|
||
public static readonly hidden = true; | ||
public static readonly deprecationOptions = { | ||
to: 'data tree export', | ||
message: messages.getMessage('LegacyDeprecation'), | ||
}; | ||
public static readonly flags = { | ||
...orgFlags, | ||
query: Flags.string({ | ||
|
@@ -35,7 +37,6 @@ export default class Export extends SfCommand<DataPlanPart[] | SObjectTreeFileCo | |
prefix: Flags.string({ | ||
char: 'x', | ||
summary: messages.getMessage('flags.prefix.summary'), | ||
parse: prefixValidation, | ||
}), | ||
'output-dir': Flags.directory({ | ||
char: 'd', | ||
|
@@ -46,15 +47,19 @@ export default class Export extends SfCommand<DataPlanPart[] | SObjectTreeFileCo | |
}; | ||
|
||
public async run(): Promise<DataPlanPart[] | SObjectTreeFileContents> { | ||
this.info( | ||
'Try the the new "sf data export beta tree" command. It support SOQL queries with up to 5 levels of objects!' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if they run the legacy command, you'll get a suggestion for a beta command, it should just b e"data export tree" right ➜ ../../oss/plugin-data/bin/run.js data export legacy tree --query "SELECT ID FROM Account"
Try the the new "sf data export beta tree" command. It support SOQL queries with up to 5 levels of objects! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. even then, ➜ ../../oss/plugin-data/bin/run.js data export beta tree --query "SELECT ID FROM Account"
› Error: command data:export:beta:tree not found There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm just going to remove that. at this point, you're intentionally choosing this old command to avoid the new one. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also, you found that I had the "beta" alias wrong on the new commands. |
||
); | ||
|
||
const { flags } = await this.parse(Export); | ||
const ux = new Ux({ jsonEnabled: this.jsonEnabled() }); | ||
const exportApi = new ExportApi(flags['target-org'], ux); | ||
const exportConfig: ExportConfig = { | ||
outputDir: flags['output-dir'], | ||
plan: flags.plan, | ||
prefix: flags.prefix, | ||
query: flags.query, | ||
conn: flags['target-org'].getConnection(flags['api-version']), | ||
ux: new Ux({ jsonEnabled: this.jsonEnabled() }), | ||
}; | ||
return runExport(exportConfig); | ||
return exportApi.export(exportConfig); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bump dev-scripts to avoid linting the .md files?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aww, it's on current dev-scripts. I don't know why that's still happening. Maybe something in vscode ext?