@salesforce/plugin-data 3.13.9 → 4.0.4

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.
@@ -1,358 +0,0 @@
1
- /*
2
- * Copyright (c) 2020, 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 util from 'node:util';
8
- import fs from 'node:fs';
9
- import path, { dirname } from 'node:path';
10
- import { fileURLToPath } from 'node:url';
11
- import { getString } from '@salesforce/ts-types';
12
- import { Logger, Messages, Org, SchemaValidator, SfError } from '@salesforce/core';
13
- import { hasNestedRecords, isAttributesElement } from '../../../types.js';
14
- Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
15
- const messages = Messages.loadMessages('@salesforce/plugin-data', 'importApi');
16
- const importPlanSchemaFile = path.join(dirname(fileURLToPath(import.meta.url)), '..', '..', '..', '..', 'schema', 'dataImportPlanSchema.json');
17
- const sobjectTreeApiPartPattern = '%s/services/data/v%s/composite/tree/%s';
18
- const jsonContentType = 'application/json';
19
- const xmlContentType = 'application/xml';
20
- const jsonRefRegex = /[.]*["|'][A-Z0-9_]*["|'][ ]*:[ ]*["|']@([A-Z0-9_]*)["|'][.]*/gim;
21
- const xmlRefRegex = /[.]*<[A-Z0-9_]*>@([A-Z0-9_]*)<\/[A-Z0-9_]*[ID]>[.]*/gim;
22
- const INVALID_DATA_IMPORT_ERR_NAME = 'InvalidDataImport';
23
- /**
24
- * Imports data into an org that was exported to files using the export API.
25
- */
26
- export class ImportApi {
27
- org;
28
- logger;
29
- responseRefs = [];
30
- sobjectUrlMap = new Map();
31
- schemaValidator;
32
- sobjectTypes = {};
33
- config;
34
- importPlanConfig = [];
35
- constructor(org) {
36
- this.org = org;
37
- this.logger = Logger.childFromRoot(this.constructor.name);
38
- this.schemaValidator = new SchemaValidator(this.logger, importPlanSchemaFile);
39
- }
40
- /**
41
- * Inserts given SObject Tree content into given target Org.
42
- *
43
- * @param config
44
- */
45
- async import(config) {
46
- const importResults = {};
47
- const instanceUrl = this.org.getField(Org.Fields.INSTANCE_URL);
48
- this.config = await this.validate(config);
49
- const refMap = new Map();
50
- const { contentType, plan, sobjectTreeFiles = [] } = this.config;
51
- try {
52
- // original version of this did files sequentially. Not sure what happens if you did it in parallel
53
- // so this still awaits each file individually
54
- if (plan) {
55
- await this.getPlanPromises({ plan, contentType, refMap, instanceUrl });
56
- }
57
- else {
58
- for (const promise of sobjectTreeFiles.map((file) => this.importSObjectTreeFile({
59
- instanceUrl,
60
- refMap,
61
- filepath: path.resolve(process.cwd(), file),
62
- contentType,
63
- }))) {
64
- // eslint-disable-next-line no-await-in-loop
65
- await promise;
66
- }
67
- }
68
- importResults.responseRefs = this.responseRefs;
69
- importResults.sobjectTypes = this.sobjectTypes;
70
- }
71
- catch (err) {
72
- if (!(err instanceof SfError)) {
73
- throw err;
74
- }
75
- const error = err;
76
- if (getString(error, 'errorCode') === 'ERROR_HTTP_400' && error.message != null) {
77
- try {
78
- const msg = JSON.parse(error.message);
79
- if (msg.hasErrors && msg.results && msg.results.length > 0) {
80
- importResults.errors = msg.results;
81
- }
82
- }
83
- catch (e2) {
84
- // throw original
85
- }
86
- }
87
- throw SfError.wrap(error);
88
- }
89
- return importResults;
90
- }
91
- getSchema() {
92
- return this.schemaValidator.loadSync();
93
- }
94
- // Does some basic validation on the filepath and returns some file metadata such as
95
- // isJson, refRegex, and headers.
96
- // eslint-disable-next-line class-methods-use-this
97
- getSObjectTreeFileMeta(filepath, contentType) {
98
- const meta = {
99
- isJson: false,
100
- headers: {},
101
- refRegex: new RegExp(/./),
102
- };
103
- let tmpContentType;
104
- // explicitly validate filepath so, if not found, we can return friendly error message
105
- try {
106
- fs.statSync(filepath);
107
- }
108
- catch (e) {
109
- throw new SfError(messages.getMessage('dataFileNotFound', [filepath]), INVALID_DATA_IMPORT_ERR_NAME);
110
- }
111
- // determine content type
112
- if (filepath.endsWith('.json')) {
113
- tmpContentType = jsonContentType;
114
- meta.isJson = true;
115
- meta.refRegex = jsonRefRegex;
116
- }
117
- else if (filepath.endsWith('.xml')) {
118
- tmpContentType = xmlContentType;
119
- meta.refRegex = xmlRefRegex;
120
- }
121
- // unable to determine content type from extension, was a global content type provided?
122
- if (!tmpContentType) {
123
- if (!contentType) {
124
- throw new SfError(messages.getMessage('unknownContentType', [filepath]), INVALID_DATA_IMPORT_ERR_NAME);
125
- }
126
- else if (contentType.toUpperCase() === 'JSON') {
127
- tmpContentType = jsonContentType;
128
- meta.isJson = true;
129
- meta.refRegex = jsonRefRegex;
130
- }
131
- else if (contentType.toUpperCase() === 'XML') {
132
- tmpContentType = xmlContentType;
133
- meta.refRegex = xmlRefRegex;
134
- }
135
- else {
136
- throw new SfError(messages.getMessage('dataFileUnsupported', [contentType]), INVALID_DATA_IMPORT_ERR_NAME);
137
- }
138
- }
139
- meta.headers['content-type'] = tmpContentType;
140
- return meta;
141
- }
142
- async getPlanPromises({ plan, contentType, refMap, instanceUrl, }) {
143
- // REVIEWME: support both files and plan in same invocation?
144
- const importPlanRootPath = dirname(plan);
145
- for (const sobjectConfig of this.importPlanConfig) {
146
- const globalSaveRefs = sobjectConfig.saveRefs ?? false;
147
- const globalResolveRefs = sobjectConfig.resolveRefs ?? false;
148
- for (const fileDef of sobjectConfig.files) {
149
- let filepath;
150
- let saveRefs = globalSaveRefs;
151
- let resolveRefs = globalResolveRefs;
152
- // file definition can be just a filepath or an object that
153
- // has a filepath and overriding global config
154
- if (typeof fileDef === 'string') {
155
- filepath = fileDef;
156
- }
157
- else if (fileDef.file) {
158
- filepath = fileDef.file;
159
- // override save references, if set
160
- saveRefs = fileDef.saveRefs ?? globalSaveRefs;
161
- // override resolve references, if set
162
- resolveRefs = fileDef.resolveRefs ?? globalResolveRefs;
163
- }
164
- else {
165
- throw new SfError('file definition format unknown.', 'InvalidDataImportPlan');
166
- }
167
- filepath = path.resolve(importPlanRootPath, filepath);
168
- const importConfig = {
169
- instanceUrl,
170
- saveRefs,
171
- resolveRefs,
172
- refMap,
173
- filepath,
174
- contentType,
175
- };
176
- // eslint-disable-next-line no-await-in-loop
177
- await this.importSObjectTreeFile(importConfig);
178
- }
179
- }
180
- }
181
- /**
182
- * Validates the import configuration. If a plan is passed, validates
183
- * the plan per the schema.
184
- *
185
- * @param config - The data import configuration.
186
- * @returns Promise.<ImportConfig>
187
- */
188
- async validate(config) {
189
- const { sobjectTreeFiles, plan } = config;
190
- // --sobjecttreefiles option is required when --plan option is unset
191
- if (!sobjectTreeFiles && !plan) {
192
- throw new SfError(messages.getMessage('dataFileNotProvided'), INVALID_DATA_IMPORT_ERR_NAME);
193
- }
194
- // Prevent both --sobjecttreefiles and --plan option from being set
195
- if (sobjectTreeFiles && plan) {
196
- throw new SfError(messages.getMessage('tooManyFiles'), INVALID_DATA_IMPORT_ERR_NAME);
197
- }
198
- if (plan) {
199
- const planPath = path.resolve(process.cwd(), plan);
200
- if (!fs.existsSync(planPath)) {
201
- throw new SfError(messages.getMessage('dataFileNotFound', [planPath]), INVALID_DATA_IMPORT_ERR_NAME);
202
- }
203
- this.importPlanConfig = JSON.parse(fs.readFileSync(planPath, 'utf8'));
204
- try {
205
- await this.schemaValidator.validate(this.importPlanConfig);
206
- }
207
- catch (err) {
208
- const error = err;
209
- if (error.name === 'ValidationSchemaFieldErrors') {
210
- throw new SfError(messages.getMessage('dataPlanValidationError', [planPath, error.message]), INVALID_DATA_IMPORT_ERR_NAME, messages.getMessages('dataPlanValidationErrorActions'));
211
- }
212
- throw SfError.wrap(error);
213
- }
214
- }
215
- return config;
216
- }
217
- /**
218
- * Create a hash of sobject { ReferenceId: Type } assigned to this.sobjectTypes.
219
- * Used to display the sobject type in the results.
220
- *
221
- * @param content The content string defined by the file(s).
222
- * @param isJson
223
- */
224
- createSObjectTypeMap(content, isJson) {
225
- const getTypes = (records) => {
226
- records.forEach((record) => {
227
- Object.entries(record).forEach(([key, val]) => {
228
- if (key === 'attributes' && isAttributesElement(val)) {
229
- this.sobjectTypes[val.referenceId] = val.type;
230
- }
231
- else if (hasNestedRecords(val) && Array.isArray(val.records)) {
232
- getTypes(val.records);
233
- }
234
- });
235
- });
236
- };
237
- if (isJson) {
238
- const contentJson = JSON.parse(content);
239
- if (Array.isArray(contentJson.records)) {
240
- getTypes(contentJson.records);
241
- }
242
- }
243
- }
244
- // Parse the SObject tree file, resolving any saved refs if specified.
245
- // Return a promise with the contents of the SObject tree file and the type.
246
- async parseSObjectTreeFile(filepath, isJson, refRegex, resolveRefs, refMap) {
247
- let contentStr;
248
- let match;
249
- let sobject = '';
250
- const foundRefs = new Set();
251
- // call identity() so the access token can be auto-updated
252
- const content = await fs.promises.readFile(filepath);
253
- if (!content) {
254
- throw messages.createError('dataFileEmpty', [filepath]);
255
- }
256
- contentStr = content.toString();
257
- if (isJson) {
258
- // is valid json? (save round-trip to server)
259
- try {
260
- const contentJson = JSON.parse(contentStr);
261
- // All top level records should be of the same sObject type so just grab the first one
262
- sobject = contentJson.records[0].attributes.type.toLowerCase();
263
- }
264
- catch (e) {
265
- throw messages.createError('dataFileInvalidJson', [filepath]);
266
- }
267
- }
268
- // if we're replacing references (@AcmeIncAccountId), find references in content and
269
- // replace with reference found in previously saved records
270
- if (resolveRefs && refMap) {
271
- // find and stash all '@' references
272
- while ((match = refRegex.exec(contentStr))) {
273
- foundRefs.add(match[1]);
274
- }
275
- if (foundRefs.size > 0 && refMap.size === 0) {
276
- throw messages.createError('dataFileNoRefId', [filepath]);
277
- }
278
- this.logger.debug(`Found references: ${Array.from(foundRefs).toString()}`);
279
- // loop thru found references and replace with id value
280
- foundRefs.forEach((ref) => {
281
- const value = refMap.get(ref.toLowerCase());
282
- if (value == null) {
283
- // REVIEWME: fail?
284
- this.logger.warn(`Reference '${ref}' not found in saved record references (${filepath})`);
285
- }
286
- else {
287
- contentStr = contentStr.replace(new RegExp(`(["'>])@${ref}(["'<])`, 'igm'), `$1${value}$2`);
288
- }
289
- });
290
- }
291
- // Create map of SObject { referenceId: type } to display the type in output
292
- this.createSObjectTypeMap(contentStr, isJson);
293
- return { contentStr, sobject };
294
- }
295
- // generate REST API url: http://<sfdc-instance>/v<version>/composite/tree/<sobject>
296
- // and send the request.
297
- async sendSObjectTreeRequest(contentStr, sobject, instanceUrl, headers) {
298
- const apiVersion = this.org.getConnection().getApiVersion();
299
- let sobjectTreeApiUrl = this.sobjectUrlMap.get(sobject);
300
- if (!sobjectTreeApiUrl) {
301
- sobjectTreeApiUrl = util.format(sobjectTreeApiPartPattern, instanceUrl, apiVersion, sobject);
302
- this.sobjectUrlMap.set(sobject, sobjectTreeApiUrl);
303
- }
304
- this.logger.debug(`SObject Tree API URL: ${sobjectTreeApiUrl}`);
305
- // post request with to-be-insert sobject tree content
306
- return this.org.getConnection().request({
307
- method: 'POST',
308
- url: sobjectTreeApiUrl,
309
- body: contentStr,
310
- headers: headers,
311
- });
312
- }
313
- // Parse the response from the SObjectTree request and save refs if specified.
314
- parseSObjectTreeResponse(response, filepath, isJson, saveRefs, refMap) {
315
- if (isJson) {
316
- this.logger.debug(`SObject Tree API results: ${JSON.stringify(response, null, 4)}`);
317
- if (response.hasErrors === true) {
318
- throw messages.createError('dataImportFailed', [filepath, JSON.stringify(response.results, null, 4)]);
319
- }
320
- if (Array.isArray(response.results)) {
321
- // REVIEWME: include filepath from which record was define?
322
- // store results to be output to stdout in aggregated tabular format
323
- this.responseRefs = this.responseRefs.concat(response.results);
324
- // if enabled, save references to map to be used to replace references
325
- // prior to subsequent saves
326
- if (saveRefs && refMap) {
327
- response.results.forEach((result) => {
328
- refMap.set(result.referenceId.toLowerCase(), result.id);
329
- });
330
- }
331
- }
332
- }
333
- else {
334
- throw new SfError('SObject Tree API XML response parsing not implemented', 'FailedDataImport');
335
- }
336
- return response;
337
- }
338
- // Imports the SObjectTree from the provided files/plan by making a POST request to the server.
339
- async importSObjectTreeFile(components) {
340
- // Get some file metadata
341
- const { isJson, refRegex, headers } = this.getSObjectTreeFileMeta(components.filepath, components.contentType);
342
- this.logger.debug(`Importing SObject Tree data from file ${components.filepath}`);
343
- try {
344
- const { contentStr, sobject } = await this.parseSObjectTreeFile(components.filepath, isJson, refRegex, components.resolveRefs, components.refMap);
345
- const response = await this.sendSObjectTreeRequest(contentStr, sobject, components.instanceUrl, headers);
346
- this.parseSObjectTreeResponse(response, components.filepath, isJson, components.saveRefs, components.refMap);
347
- }
348
- catch (error) {
349
- if (error instanceof Error && getString(error, 'errorCode') === 'INVALID_FIELD') {
350
- const field = error.message.split("'")[1];
351
- const object = error.message.substr(error.message.lastIndexOf(' ') + 1, error.message.length);
352
- throw messages.createError('FlsError', [field, object]);
353
- }
354
- throw SfError.wrap(error);
355
- }
356
- }
357
- }
358
- //# sourceMappingURL=importApi.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"importApi.js","sourceRoot":"","sources":["../../../../src/api/data/tree/importApi.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,EAAE,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAuB,SAAS,EAAW,MAAM,sBAAsB,CAAC;AAC/E,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AACnF,OAAO,EAAgB,gBAAgB,EAAE,mBAAmB,EAAoB,MAAM,mBAAmB,CAAC;AAG1G,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,yBAAyB,EAAE,WAAW,CAAC,CAAC;AAE/E,MAAM,oBAAoB,GAAG,IAAI,CAAC,IAAI,CACpC,OAAO,CA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CACF"}
@@ -1,58 +0,0 @@
1
- /*
2
- * Copyright (c) 2020, 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 { Messages } from '@salesforce/core';
8
- import { SfCommand, Flags, Ux } from '@salesforce/sf-plugins-core';
9
- import { orgFlags } from '../../../../flags.js';
10
- import { ExportApi } from '../../../../api/data/tree/exportApi.js';
11
- Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
12
- const messages = Messages.loadMessages('@salesforce/plugin-data', 'tree.export');
13
- export default class Export extends SfCommand {
14
- static summary = messages.getMessage('summary');
15
- static description = messages.getMessage('description');
16
- static examples = messages.getMessages('examples');
17
- static hidden = true;
18
- static state = 'deprecated';
19
- static deprecationOptions = {
20
- to: 'data tree export',
21
- message: messages.getMessage('LegacyDeprecation'),
22
- };
23
- static flags = {
24
- ...orgFlags,
25
- query: Flags.string({
26
- char: 'q',
27
- summary: messages.getMessage('flags.query.summary'),
28
- required: true,
29
- }),
30
- plan: Flags.boolean({
31
- char: 'p',
32
- summary: messages.getMessage('flags.plan.summary'),
33
- }),
34
- prefix: Flags.string({
35
- char: 'x',
36
- summary: messages.getMessage('flags.prefix.summary'),
37
- }),
38
- 'output-dir': Flags.directory({
39
- char: 'd',
40
- summary: messages.getMessage('flags.output-dir.summary'),
41
- aliases: ['outputdir'],
42
- deprecateAliases: true,
43
- }),
44
- };
45
- async run() {
46
- const { flags } = await this.parse(Export);
47
- const ux = new Ux({ jsonEnabled: this.jsonEnabled() });
48
- const exportApi = new ExportApi(flags['target-org'], ux);
49
- const exportConfig = {
50
- outputDir: flags['output-dir'],
51
- plan: flags.plan,
52
- prefix: flags.prefix,
53
- query: flags.query,
54
- };
55
- return exportApi.export(exportConfig);
56
- }
57
- }
58
- //# sourceMappingURL=tree.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tree.js","sourceRoot":"","sources":["../../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AQ,CAAC,UAAU,CAAC,oBAAoB,CAAC;SACnD,CAAC;QACF,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC;YACnB,IAAI,EAAE,GAAG;YACT,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,sBAAsB,CAAC;SACrD,CAAC;QACF,YAAY,EAAE,KAAK,CAAC,SAAS,CAAC;YAC5B,IAAI,EAAE,GAAG;YACT,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,0BAA0B,CAAC;YACxD,OAAO,EAAE,CAAC,WAAW,CAAC;YACtB,gBAAgB,EAAE,IAAI;SACvB,CAAC;KACH,CAAC;IAEK,KAAK,CAAC,GAAG;QACd,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAC3C,MAAM,EAAE,GAAG,IAAI,EAAE,CAAC,EAAE,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;QACvD,MAAM,SAAS,GAAG,IAAI,SAAS,CAAC,KAAK,CAAC,YAAY,CAAC,EAAE,EAAE,CAAC,CAAC;QACzD,MAAM,YAAY,GAAiB;YACjC,SAAS,EAAE,KAAK,CAAC,YAAY,CAAC;YAC9B,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,KAAK,EAAE,KAAK,CAAC,KAAK;SACnB,CAAC;QACF,OAAO,SAAS,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IACxC,CAAC"}
@@ -1,84 +0,0 @@
1
- /*
2
- * Copyright (c) 2020, 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 { Messages } from '@salesforce/core';
8
- import { getString } from '@salesforce/ts-types';
9
- import { SfCommand, Flags, arrayWithDeprecation } from '@salesforce/sf-plugins-core';
10
- import { ImportApi } from '../../../../api/data/tree/importApi.js';
11
- import { orgFlags } from '../../../../flags.js';
12
- Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
13
- const messages = Messages.loadMessages('@salesforce/plugin-data', 'tree.import.legacy');
14
- /**
15
- * Command that provides data import capability via the SObject Tree Save API.
16
- */
17
- export default class Import extends SfCommand {
18
- static summary = messages.getMessage('summary');
19
- static description = messages.getMessage('description');
20
- static examples = messages.getMessages('examples');
21
- static hidden = true;
22
- static state = 'deprecated';
23
- static deprecationOptions = {
24
- message: messages.getMessage('deprecation'),
25
- };
26
- static flags = {
27
- ...orgFlags,
28
- files: arrayWithDeprecation({
29
- char: 'f',
30
- summary: messages.getMessage('flags.files.summary'),
31
- exclusive: ['plan'],
32
- aliases: ['sobjecttreefiles'],
33
- deprecateAliases: true,
34
- }),
35
- plan: Flags.file({
36
- char: 'p',
37
- summary: messages.getMessage('flags.plan.summary'),
38
- exists: true,
39
- }),
40
- 'content-type': Flags.string({
41
- char: 'c',
42
- summary: messages.getMessage('flags.content-type.summary'),
43
- hidden: true,
44
- aliases: ['contenttype'],
45
- deprecateAliases: true,
46
- deprecated: { message: messages.getMessage('flags.content-type.deprecation') },
47
- }),
48
- // displays the schema for a data import plan
49
- 'config-help': Flags.boolean({
50
- summary: messages.getMessage('flags.config-help.summary'),
51
- aliases: ['confighelp'],
52
- deprecateAliases: true,
53
- hidden: true,
54
- deprecated: { message: messages.getMessage('flags.config-help.deprecation') },
55
- }),
56
- };
57
- async run() {
58
- const { flags } = await this.parse(Import);
59
- const importApi = new ImportApi(flags['target-org']);
60
- if (flags['config-help']) {
61
- // Display config help and return
62
- const schema = importApi.getSchema();
63
- this.log(messages.getMessage('schema-help'));
64
- return schema;
65
- }
66
- const importConfig = {
67
- sobjectTreeFiles: flags.files,
68
- contentType: flags['content-type'],
69
- plan: flags.plan,
70
- };
71
- const importResults = await importApi.import(importConfig);
72
- const processedResult = (importResults.responseRefs ?? []).map((ref) => {
73
- const type = getString(importResults.sobjectTypes, ref.referenceId, 'Unknown');
74
- return { refId: ref.referenceId, type, id: ref.id };
75
- });
76
- this.table({
77
- data: processedResult,
78
- columns: [{ key: 'refId', name: 'Reference ID' }, 'type', { key: 'id', name: 'ID' }],
79
- title: 'Import Results',
80
- });
81
- return processedResult;
82
- }
83
- }
84
- //# sourceMappingURL=tree.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tree.js","sourceRoot":"","sources":["../../../../../src/commands/data/import/legacy/tree.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAW,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAErF,OAAO,EAAE,SAAS,EAAgB,MAAM,wCAAwC,CAAC;AACjF,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEhD,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,yBAAyB,EAAE,oBAAoB,CAAC,CAAC;AAExF;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,MAAO,SAAQ,SAAmC;IAC9D,MAAM,CAAU,OAAO,GAAG,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;IACzD,MAAM,CAAU,WAAW,GAAG,QAAQ,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;IACjE,MAAM,CAAU,QAAQ,GAAG,QAAQ,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;IAC5D,MAAM,CAAU,MAAM,GAAG,IAAI,CAAC;IAC9B,MAAM,CAAU,KAAK,GAAG,YAAY,CAAC;IACrC,MAAM,CAAC,kBAAkB,GAAG;QACjC,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,aAAa,CAAC;KAC5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AC,CAAC;QAErD,IAAI,KAAK,CAAC,aAAa,CAAC,EAAE,CAAC;YACzB,iCAAiC;YACjC,MAAM,MAAM,GAAG,SAAS,CAAC,SAAS,EAAE,CAAC;YACrC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC;YAE7C,OAAO,MAAM,CAAC;QAChB,CAAC;QAED,MAAM,YAAY,GAAiB;YACjC,gBAAgB,EAAE,KAAK,CAAC,KAAK;YAC7B,WAAW,EAAE,KAAK,CAAC,cAAc,CAAC;YAClC,IAAI,EAAE,KAAK,CAAC,IAAI;SACjB,CAAC;QAEF,MAAM,aAAa,GAAG,MAAM,SAAS,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;QAE3D,MAAM,eAAe,GAAmB,CAAC,aAAa,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;YACrF,MAAM,IAAI,GAAG,SAAS,CAAC,aAAa,CAAC,YAAY,EAAE,GAAG,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;YAC/E,OAAO,EAAE,KAAK,EAAE,GAAG,CAAC,WAAW,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC;QACtD,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,KAAK,CAAC;YACT,IAAI,EAAE,eAAe;YACrB,OAAO,EAAE,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;YACpF,KAAK,EAAE,gBAAgB;SACxB,CAAC,CAAC;QAEH,OAAO,eAAe,CAAC;IACzB,CAAC"}
@@ -1,60 +0,0 @@
1
- # summary
2
-
3
- Import data from one or more JSON files into an org.
4
-
5
- # description
6
-
7
- 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.
8
-
9
- 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.
10
-
11
- 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)
12
-
13
- # flags.files.summary
14
-
15
- Comma-separated and in-order JSON files that contain the records, in sObject tree format, that you want to insert.
16
-
17
- # flags.plan.summary
18
-
19
- Plan definition file to insert multiple data files.
20
-
21
- # flags.content-type.summary
22
-
23
- Content type of import files if their extention is not .json.
24
-
25
- # flags.content-type.deprecation
26
-
27
- 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.
28
-
29
- # flags.config-help.summary
30
-
31
- Display schema information for the --plan configuration file to stdout; if you specify this flag, all other flags except --json are ignored.
32
-
33
- # flags.config-help.deprecation
34
-
35
- 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.
36
-
37
- # examples
38
-
39
- - Import the records contained in two JSON files into the org with alias "my-scratch":
40
-
41
- <%= config.bin %> <%= command.id %> --files Contact.json,Account.json --target-org my-scratch
42
-
43
- - Import records using a plan definition file into your default org:
44
-
45
- <%= config.bin %> <%= command.id %> --plan Account-Contact-plan.json
46
-
47
- # schema-help
48
-
49
- schema(array) - Data Import Plan: Schema for SFDX Toolbelt's data import plan JSON.
50
-
51
- - items(object) - SObject Type: Definition of records to be insert per SObject Type
52
- - sobject(string) - Name of SObject: Child file references must have SObject roots of this type
53
- - 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.
54
- - resolveRefs(boolean) - Resolve References: Pre-save, replace @<reference> with ID from previous save. Applies to all data files for this SObject type.
55
- - files(array) - Files: An array of files paths to load
56
- - items(string|object) - Filepath: Filepath string or object to point to a JSON or XML file having data defined in SObject Tree format.
57
-
58
- # deprecation
59
-
60
- After Nov 10, 2024, this command will no longer be available. Use `data export tree`.