@kitalive/sfdx-plugin 0.1.6 → 0.2.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,18 @@
1
+ import { flags, SfdxCommand } from '@salesforce/command';
2
+ import { BulkResult } from '../../../../bulk';
3
+ export default class DeleteCommand extends SfdxCommand {
4
+ static description: string;
5
+ static examples: string[];
6
+ protected static requiresUsername: boolean;
7
+ protected static requiresProject: boolean;
8
+ protected static flagsConfig: {
9
+ query: flags.Discriminated<flags.String>;
10
+ hard: flags.Discriminated<flags.Boolean<boolean>>;
11
+ concurrencymode: flags.Discriminated<flags.String>;
12
+ batchsize: flags.Discriminated<flags.Number>;
13
+ wait: flags.Discriminated<flags.Number>;
14
+ };
15
+ run(): Promise<BulkResult>;
16
+ private bulkQuery;
17
+ private bulkLoad;
18
+ }
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const command_1 = require("@salesforce/command");
4
+ const soql_parser_js_1 = require("soql-parser-js");
5
+ const bulk_1 = require("../../../../bulk");
6
+ class DeleteCommand extends command_1.SfdxCommand {
7
+ async run() {
8
+ const query = soql_parser_js_1.parseQuery(this.flags.query);
9
+ query.fields = [soql_parser_js_1.getField('Id')];
10
+ const soql = soql_parser_js_1.composeQuery(query);
11
+ const conn = this.org.getConnection();
12
+ const { concurrencymode: concurrencyMode, batchsize: batchSize, wait, hard } = this.flags;
13
+ this.ux.startSpinner(hard ? 'Bulk hard delete' : 'Bulk delete');
14
+ try {
15
+ const rows = await this.bulkQuery(conn, soql);
16
+ if (!rows.length) {
17
+ this.ux.stopSpinner('no records');
18
+ return { records: [] };
19
+ }
20
+ const operation = hard ? 'hardDelete' : 'delete';
21
+ const result = await this.bulkLoad(conn, query.sObject, operation, rows, { concurrencyMode, batchSize, wait });
22
+ if (wait) {
23
+ const { numberRecordsProcessed, numberRecordsFailed } = result.job;
24
+ const errors = result.records.filter(r => !r.success).map(r => ({ id: r.id, errors: r.errors.join(', ') }));
25
+ this.ux.stopSpinner(`${numberRecordsProcessed} processed, ${numberRecordsFailed} failed.`);
26
+ if (errors.length) {
27
+ this.ux.styledHeader('Error details');
28
+ this.ux.table(errors, ['id', 'errors']);
29
+ }
30
+ }
31
+ else {
32
+ this.ux.stopSpinner();
33
+ this.ux.log('Check bulk job status with the command: ');
34
+ this.ux.log(`sfdx force:org:open -u ${this.flags.targetusername} -p "lightning/setup/AsyncApiJobStatus/page?address=%2F${result.job.id}"`);
35
+ }
36
+ return result;
37
+ }
38
+ catch (e) {
39
+ this.ux.stopSpinner('error');
40
+ throw e;
41
+ }
42
+ }
43
+ bulkQuery(conn, query) {
44
+ return bulk_1.bulkQuery(conn, query);
45
+ }
46
+ bulkLoad(conn, sobject, operation, rows, options) {
47
+ return bulk_1.bulkLoad(conn, sobject, operation, rows, options);
48
+ }
49
+ }
50
+ exports.default = DeleteCommand;
51
+ DeleteCommand.description = 'bulk delete records by SOQL select query';
52
+ DeleteCommand.examples = [
53
+ '$ sfdx kit:data:bulk:delete -q \'SELECT Id FROM Opportunity WHERE CloseDate < LAST_N_YEARS:5\''
54
+ ];
55
+ DeleteCommand.requiresUsername = true;
56
+ DeleteCommand.requiresProject = false;
57
+ DeleteCommand.flagsConfig = {
58
+ query: command_1.flags.string({ char: 'q', required: true, description: 'SOQL query to delete' }),
59
+ hard: command_1.flags.boolean({ default: false, description: 'perform a hard delete' }),
60
+ concurrencymode: command_1.flags.string({ default: 'Parallel', description: 'the concurrency mode (Parallel or Serial) for the job' }),
61
+ batchsize: command_1.flags.integer({ char: 's', min: 1, max: 10000, default: 10000, description: 'the batch size of the job' }),
62
+ wait: command_1.flags.integer({ char: 'w', min: 0, description: 'the number of minutes to wait for the command to complete before displaying the results' })
63
+ };
64
+ //# sourceMappingURL=delete.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delete.js","sourceRoot":"","sources":["../../../../../src/commands/kit/data/bulk/delete.ts"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E,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAC3D,CAAC;;AAhEH,gCAiEC;AAhEe,yBAAW,GAAG,0CAA0C,CAAC;AAEzD,sBAAQ,GAAG;IACvB,gGAAgG;CACjG,CAAC;AAEe,8BAAgB,GAAG,IAAI,CAAC;AACxB,6BAAe,GAAG,KAAK,CAAC;AAExB,yBAAW,GAAG;IAC7B,KAAK,EAAE,eAAK,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,sBAAsB,EAAE,CAAC;IACvF,IAAI,EAAE,eAAK,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,uBAAuB,EAAE,CAAC;IAC7E,eAAe,EAAE,eAAK,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,uDAAuD,EAAE,CAAC;IAC5H,SAAS,EAAE,eAAK,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,2BAA2B,EAAE,CAAC;IACrH,IAAI,EAAE,eAAK,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,WAAW,EAAE,yFAAyF,EAAE,CAAC;CACnJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ declare const _default: new (...args: any[]) => import("@salesforce/command").SfdxCommand;
2
+ export default _default;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const bulk_1 = require("../../../../bulk");
4
+ exports.default = bulk_1.createBulkCommand('insert');
5
+ //# sourceMappingURL=insert.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"insert.js","sourceRoot":"","sources":["../../../../../src/commands/kit/data/bulk/insert.ts"],"names":[],"mappings":";;AAAA,2CAAqD;AAErD,kBAAe,wBAAiB,CAAC,QAAQ,CAAC,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { flags, SfdxCommand } from '@salesforce/command';
2
+ import { JsonMap } from '@salesforce/ts-types';
3
+ export default class QueryCommand extends SfdxCommand {
4
+ static description: string;
5
+ static examples: string[];
6
+ protected static requiresUsername: boolean;
7
+ protected static requiresProject: boolean;
8
+ protected static flagsConfig: {
9
+ query: flags.Discriminated<flags.String>;
10
+ csvfile: flags.Discriminated<flags.String>;
11
+ };
12
+ run(): Promise<JsonMap[]>;
13
+ private writeCsv;
14
+ private bulkQuery;
15
+ }
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const format_1 = require("@fast-csv/format");
4
+ const command_1 = require("@salesforce/command");
5
+ const fs = require("fs");
6
+ const bulk_1 = require("../../../../bulk");
7
+ class QueryCommand extends command_1.SfdxCommand {
8
+ async run() {
9
+ const conn = this.org.getConnection();
10
+ const file = this.flags.csvfile;
11
+ this.ux.startSpinner('Bulk query');
12
+ try {
13
+ const rows = await this.bulkQuery(conn, this.flags.query);
14
+ if (!rows.length) {
15
+ this.ux.stopSpinner('no records');
16
+ return rows;
17
+ }
18
+ this.ux.stopSpinner(`${rows.length} records`);
19
+ if (file) {
20
+ this.writeCsv(rows, fs.createWriteStream(file));
21
+ }
22
+ else if (!this.flags.json) {
23
+ this.writeCsv(rows, process.stdout);
24
+ }
25
+ return rows;
26
+ }
27
+ catch (e) {
28
+ this.ux.stopSpinner('error');
29
+ throw e;
30
+ }
31
+ }
32
+ writeCsv(rows, stream) {
33
+ format_1.write(rows, { headers: true, writeBOM: true }).pipe(stream);
34
+ }
35
+ bulkQuery(conn, query) {
36
+ return bulk_1.bulkQuery(conn, query);
37
+ }
38
+ }
39
+ exports.default = QueryCommand;
40
+ QueryCommand.description = 'bulk query records';
41
+ QueryCommand.examples = [
42
+ '$ sfdx kit:data:bulk:query -q \'SELECT Id, Name FROM Account\' -f ./path/to/Account.csv'
43
+ ];
44
+ QueryCommand.requiresUsername = true;
45
+ QueryCommand.requiresProject = false;
46
+ QueryCommand.flagsConfig = {
47
+ query: command_1.flags.string({ char: 'q', required: true, description: 'SOQL query to export' }),
48
+ csvfile: command_1.flags.string({ char: 'f', description: 'output csv file (default: standard output)' })
49
+ };
50
+ //# sourceMappingURL=query.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query.js","sourceRoot":"","sources":["../../../../../src/commands/kit/data/bulk/query.ts"],"names":[],"mappings":";;AAAA,6CAAyC;AACzC,iDAAyD;AAEzD,yBAAyB;AACzB,2CAA6C;AAE7C,MAAqB,YAAa,SAAQ,qBAAW;IAe5C,KAAK,CAAC,GAAG;QACd,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,aAAa,EAAE,CAAC;QACtC,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC;QAEhC,IAAI,CAAC,EAAE,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;QACnC,IAAI;YACF,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YAC1D,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;gBAChB,IAAI,CAAC,EAAE,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;gBAClC,OAAO,IAAI,CAAC;aACb;YAED,IAAI,CAAC,EAAE,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC,MAAM,UAAU,CAAC,CAAC;YAE9C,IAAI,IAAI,EAAE;gBACR,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC;aACjD;iBAAM,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE;gBAC3B,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;aACrC;YAED,OAAO,IAAI,CAAC;SACb;QAAC,OAAO,CAAC,EAAE;YACV,IAAI,CAAC,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;YAC7B,MAAM,CAAC,CAAC;SACT;IACH,CAAC;IAEO,QAAQ,CAAC,IAAI,EAAE,MAAM;QAC3B,cAAK,CAAC,IAAI,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC9D,CAAC;IAEO,SAAS,CAAC,IAAI,EAAE,KAAK;QAC3B,OAAO,gBAAS,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAChC,CAAC;;AAhDH,+BAiDC;AAhDe,wBAAW,GAAG,oBAAoB,CAAC;AAEnC,qBAAQ,GAAG;IACvB,yFAAyF;CAC1F,CAAC;AAEe,6BAAgB,GAAG,IAAI,CAAC;AACxB,4BAAe,GAAG,KAAK,CAAC;AAExB,wBAAW,GAAG;IAC7B,KAAK,EAAE,eAAK,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,sBAAsB,EAAE,CAAC;IACvF,OAAO,EAAE,eAAK,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,WAAW,EAAE,4CAA4C,EAAE,CAAC;CAChG,CAAC"}
@@ -0,0 +1,2 @@
1
+ declare const _default: new (...args: any[]) => import("@salesforce/command").SfdxCommand;
2
+ export default _default;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const bulk_1 = require("../../../../bulk");
4
+ exports.default = bulk_1.createBulkCommand('update');
5
+ //# sourceMappingURL=update.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update.js","sourceRoot":"","sources":["../../../../../src/commands/kit/data/bulk/update.ts"],"names":[],"mappings":";;AAAA,2CAAqD;AAErD,kBAAe,wBAAiB,CAAC,QAAQ,CAAC,CAAC"}
@@ -1,49 +1,2 @@
1
- /// <reference types="node" />
2
- import { flags, SfdxCommand } from '@salesforce/command';
3
- import { JsonMap } from '@salesforce/ts-types';
4
- import { Readable } from 'stream';
5
- export default class UpsertCommand extends SfdxCommand {
6
- static description: string;
7
- static examples: string[];
8
- protected static requiresUsername: boolean;
9
- protected static requiresProject: boolean;
10
- protected static flagsConfig: {
11
- object: flags.Discriminated<flags.String>;
12
- externalid: flags.Discriminated<flags.String>;
13
- csvfile: flags.Discriminated<flags.String>;
14
- resultfile: flags.Discriminated<flags.String>;
15
- encoding: flags.Discriminated<flags.String>;
16
- delimiter: flags.Discriminated<flags.String>;
17
- quote: flags.Discriminated<flags.String>;
18
- skiplines: flags.Discriminated<flags.Number>;
19
- trim: flags.Discriminated<flags.Boolean<boolean>>;
20
- mapping: flags.Discriminated<flags.String>;
21
- converter: flags.Discriminated<flags.String>;
22
- setnull: flags.Discriminated<flags.Boolean<boolean>>;
23
- convertonly: flags.Discriminated<flags.Boolean<boolean>>;
24
- concurrencymode: flags.Discriminated<flags.String>;
25
- assignmentruleid: flags.Discriminated<flags.String>;
26
- batchsize: flags.Discriminated<flags.Number>;
27
- wait: flags.Discriminated<flags.Number>;
28
- };
29
- run(): Promise<JsonMap>;
30
- parseCsv(input: Readable, options?: {
31
- encoding?: string;
32
- delimiter?: string;
33
- quote?: string;
34
- skiplines?: number;
35
- trim?: boolean;
36
- setnull?: boolean;
37
- mapping?: JsonMap;
38
- convert?: (row: JsonMap) => JsonMap | null | undefined;
39
- fieldTypes?: {
40
- [field: string]: string;
41
- };
42
- }): Promise<JsonMap[]>;
43
- private executeBatches;
44
- private executeBatch;
45
- private saveCsv;
46
- private loadScript;
47
- private getFieldTypes;
48
- private createJob;
49
- }
1
+ declare const _default: new (...args: any[]) => import("@salesforce/command").SfdxCommand;
2
+ export default _default;
@@ -1,212 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const command_1 = require("@salesforce/command");
4
- const dayjs = require("dayjs");
5
- const csv = require("fast-csv");
6
- const fs = require("fs-extra");
7
- const path = require("path");
8
- const utils_1 = require("../../../../utils");
9
- const convert_1 = require("../csv/convert");
10
- const convert_2 = require("../csv/convert");
11
- function normalizeDateString(str, format) {
12
- if (!str)
13
- return str;
14
- const d = dayjs(str);
15
- return format ? d.format(format) : d.toISOString();
16
- }
17
- const converters = {
18
- date: value => normalizeDateString(value, 'YYYY-MM-DD'),
19
- datetime: normalizeDateString
20
- };
21
- const csvFlags = convert_1.default['flagsConfig'];
22
- class UpsertCommand extends command_1.SfdxCommand {
23
- async run() {
24
- const { csvfile, mapping, converter, encoding, delimiter, quote, skiplines, trim, setnull } = this.flags;
25
- const mappingJson = (mapping) ? (await fs.readJson(mapping)) : undefined;
26
- const script = converter ? this.loadScript(converter) : {};
27
- const fieldTypes = await this.getFieldTypes(this.flags.object);
28
- this.ux.startSpinner('Processing csv');
29
- if (script.start)
30
- await script.start(this);
31
- let rows = await this.parseCsv(fs.createReadStream(csvfile), {
32
- encoding,
33
- delimiter,
34
- quote,
35
- skiplines,
36
- trim: !!trim,
37
- setnull,
38
- mapping: mappingJson,
39
- convert: script.convert,
40
- fieldTypes
41
- });
42
- if (script.finish) {
43
- const result = await script.finish(rows, this);
44
- if (result)
45
- rows = result;
46
- }
47
- this.ux.stopSpinner();
48
- if (this.flags.convertonly) {
49
- const base = path.basename(csvfile, path.extname(csvfile));
50
- this.saveCsv(path.join(path.dirname(csvfile), base + '.converted.csv'), rows);
51
- return;
52
- }
53
- this.ux.startSpinner('Bulk Upsert');
54
- let job;
55
- try {
56
- job = await this.createJob(this.flags.object, {
57
- extIdField: this.flags.externalid,
58
- concurrencyMode: this.flags.concurrencymode,
59
- assignmentRuleId: this.flags.assignmentruleid
60
- });
61
- const batchResults = await this.executeBatches(job, rows, this.flags.batchsize, this.flags.wait);
62
- const batchErrors = [];
63
- if (this.flags.wait) {
64
- rows = rows.map((data, i) => {
65
- var _a;
66
- const { id, errors } = (_a = batchResults[i]) !== null && _a !== void 0 ? _a : {};
67
- const message = errors === null || errors === void 0 ? void 0 : errors.join(', ');
68
- if (message) {
69
- batchErrors.push({ line: i + 2, message, data });
70
- }
71
- return Object.assign(Object.assign({}, data), { Id: id, Errors: message });
72
- });
73
- if (batchErrors.length) {
74
- this.ux.styledHeader('Upsert errors');
75
- batchErrors.forEach(({ line, message }) => this.ux.log(`line ${line}: ${message}`));
76
- }
77
- }
78
- else {
79
- const batchInfos = await job.list();
80
- let command = 'sfdx force:data:bulk:status';
81
- if (this.flags.targetusername)
82
- command += ' -u ' + this.flags.targetusername;
83
- batchInfos.forEach((batch, i) => this.ux.log([
84
- `Check batch #${i + 1}’s status with the command: `,
85
- `${command} -i ${batch.jobId} -b ${batch.id}`
86
- ].join('\n')));
87
- }
88
- if (this.flags.resultfile)
89
- this.saveCsv(this.flags.resultfile, rows);
90
- const jobInfo = await job.check();
91
- delete jobInfo.$;
92
- delete jobInfo.state;
93
- if (this.flags.wait) {
94
- this.ux.styledHeader('Job Status');
95
- this.ux.styledObject(jobInfo, Object.keys(jobInfo));
96
- }
97
- if (batchErrors.length)
98
- jobInfo.errors = batchErrors;
99
- return jobInfo;
100
- }
101
- catch (e) {
102
- this.ux.stopSpinner('error');
103
- throw e;
104
- }
105
- finally {
106
- job === null || job === void 0 ? void 0 : job.close();
107
- }
108
- }
109
- async parseCsv(input, options) {
110
- const { encoding, delimiter, quote, skiplines, trim, mapping, convert, setnull, fieldTypes } = options !== null && options !== void 0 ? options : {};
111
- return await convert_2.parseCsv(input, { encoding, delimiter, quote, skiplines, trim, mapping, convert: row => {
112
- const result = convert ? convert(row) : row;
113
- if (!result)
114
- return;
115
- if (fieldTypes) {
116
- for (const key of Object.keys(result)) {
117
- const converter = converters[fieldTypes[key]];
118
- if (converter)
119
- result[key] = converter(result[key]);
120
- }
121
- }
122
- if (setnull) {
123
- for (const key of Object.keys(result)) {
124
- if (key.includes('.'))
125
- continue; // skip reference
126
- if (result[key] == null || result[key] === '')
127
- result[key] = '#N/A';
128
- }
129
- }
130
- return result;
131
- } });
132
- }
133
- executeBatches(job, rows, batchSize, wait) {
134
- return Promise.all(utils_1.chunk(rows, batchSize).map(batchRows => this.executeBatch(job, batchRows, wait))).then(result => result.flat());
135
- }
136
- executeBatch(job, rows, wait) {
137
- return new Promise((resolve, reject) => {
138
- const batch = job.createBatch();
139
- batch.on('error', e => {
140
- if (e.message.startsWith('Polling time out'))
141
- job.emit('error', e);
142
- reject(e);
143
- });
144
- batch.on('queue', batchInfo => {
145
- batch.check().then(result => {
146
- if (result.state === 'Failed') {
147
- reject(result.stateMessage);
148
- }
149
- else if (wait) {
150
- batch.poll(5000, wait * 60000);
151
- }
152
- else {
153
- resolve([]);
154
- }
155
- });
156
- });
157
- batch.on('response', resolve);
158
- batch.execute(rows, error => error && reject(error));
159
- });
160
- }
161
- saveCsv(file, rows) {
162
- csv.writeToPath(file, rows, { headers: true });
163
- }
164
- loadScript(file) {
165
- return convert_2.loadScript(file);
166
- }
167
- async getFieldTypes(sobject) {
168
- const conn = this.org.getConnection();
169
- const objectInfo = await conn.describe(sobject);
170
- return objectInfo.fields.reduce((info, { name, type }) => Object.assign(info, { [name]: type }), {});
171
- }
172
- async createJob(sobject, options) {
173
- const conn = this.org.getConnection();
174
- const job = conn.bulk.createJob(sobject, 'upsert', options);
175
- await job.on('error', e => { throw e; }).open();
176
- return job;
177
- }
178
- }
179
- exports.default = UpsertCommand;
180
- UpsertCommand.description = [
181
- 'bulk upsert records from a CSV file',
182
- 'Upsert records using Bulk API and returns a job ID and a batch ID. Use these IDs to check job status with data:bulk:status.',
183
- 'For information about CSV file formats, see [Prepare CSV Files](https://developer.salesforce.com/docs/atlas.en-us.api_asynch.meta/api_asynch/datafiles_csv_preparing.htm) in the Bulk API Developer Guide.'
184
- ].join('\n');
185
- UpsertCommand.examples = [
186
- '$ sfdx kit:data:bulk:upsert -o Account -f ./path/to/Account.csv -m ./path/to/mapping.json',
187
- '$ sfdx kit:data:bulk:upsert -o MyObject__c -f ./path/to/MyObject__c.csv -c ./path/to/convert.js -i MyExternalId__c -w 10'
188
- ];
189
- UpsertCommand.requiresUsername = true;
190
- UpsertCommand.requiresProject = false;
191
- UpsertCommand.flagsConfig = {
192
- object: command_1.flags.string({ char: 'o', required: true, description: 'the sObject name to upsert' }),
193
- externalid: command_1.flags.string({ char: 'i', required: true, default: 'Id', description: 'the column name of the external ID' }),
194
- // csv settings
195
- csvfile: command_1.flags.filepath({ char: 'f', required: true, description: 'the CSV file path that defines the records to upsert' }),
196
- resultfile: command_1.flags.filepath({ char: 'r', description: 'the CSV file path for writing the upsert results' }),
197
- encoding: csvFlags.encoding,
198
- delimiter: csvFlags.delimiter,
199
- quote: csvFlags.quote,
200
- skiplines: csvFlags.skiplines,
201
- trim: csvFlags.trim,
202
- mapping: csvFlags.mapping,
203
- converter: csvFlags.converter,
204
- setnull: command_1.flags.boolean({ description: 'set blank values as null values during upsert operations (default: empty field values are ignored)' }),
205
- convertonly: command_1.flags.boolean({ description: 'output converted.csv file and skip upsert for debugging' }),
206
- // job settings
207
- concurrencymode: command_1.flags.string({ default: 'Parallel', description: 'the concurrency mode (Parallel or Serial) for the job' }),
208
- assignmentruleid: command_1.flags.string({ description: 'the ID of a specific assignment rule to run for a case or a lead.' }),
209
- batchsize: command_1.flags.integer({ char: 's', min: 1, max: 10000, default: 10000, description: 'the batch size of the job' }),
210
- wait: command_1.flags.integer({ char: 'w', min: 0, description: 'the number of minutes to wait for the command to complete before displaying the results' })
211
- };
3
+ const bulk_1 = require("../../../../bulk");
4
+ exports.default = bulk_1.createBulkCommand('upsert');
212
5
  //# sourceMappingURL=upsert.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"upsert.js","sourceRoot":"","sources":["../../../../../src/commands/kit/data/bulk/upsert.ts"],"names":[],"mappings":";;AAAA,iDAAyD;AAEzD,+BAA+B;AAC/B,gCAAgC;AA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mE,EAAE,CAAC;IACpH,SAAS,EAAE,eAAK,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,2BAA2B,EAAE,CAAC;IACrH,IAAI,EAAE,eAAK,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,WAAW,EAAE,yFAAyF,EAAE,CAAC;CACnJ,CAAC"}
1
+ {"version":3,"file":"upsert.js","sourceRoot":"","sources":["../../../../../src/commands/kit/data/bulk/upsert.ts"],"names":[],"mappings":";;AAAA,2CAAqD;AAErD,kBAAe,wBAAiB,CAAC,QAAQ,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":"0.1.6","commands":{"kit:script:execute":{"id":"kit:script:execute","description":"execute Node.js scripts in SfdxCommand context\nAvailable variables in Node.js scripts\n argv: Parsed command line arguments after the file option\n conn: jsforce Connection\n context: SfdxCommand","usage":"<%= command.id %> [-f <filepath>] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]","pluginName":"@kitalive/sfdx-plugin","pluginType":"core","aliases":["kit:script"],"examples":["$ sfdx kit:script -f ./path/to/script.js","$ sfdx kit:script:execute","> await conn.query('SELECT Id, Name FROM Account LIMIT 1')","Top level await is not enabled by default in REPL before Node.js v16","$ NODE_OPTIONS=--experimental-repl-await sfdx kit:script:execute"],"flags":{"json":{"name":"json","type":"boolean","description":"format output as json","allowNo":false},"loglevel":{"name":"loglevel","type":"option","description":"logging level for this command invocation","required":false,"helpValue":"(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL)","options":["trace","debug","info","warn","error","fatal","TRACE","DEBUG","INFO","WARN","ERROR","FATAL"],"default":"warn"},"targetusername":{"name":"targetusername","type":"option","char":"u","description":"username or alias for the target org; overrides default target org"},"apiversion":{"name":"apiversion","type":"option","description":"override the api version used for api requests made by this command"},"file":{"name":"file","type":"option","char":"f","description":"the path of the Node.js script file to execute"}},"args":[]},"kit:data:bulk:upsert":{"id":"kit:data:bulk:upsert","description":"bulk upsert records from a CSV file\nUpsert records using Bulk API and returns a job ID and a batch ID. Use these IDs to check job status with data:bulk:status.\nFor information about CSV file formats, see [Prepare CSV Files](https://developer.salesforce.com/docs/atlas.en-us.api_asynch.meta/api_asynch/datafiles_csv_preparing.htm) in the Bulk API Developer Guide.","usage":"<%= command.id %> -o <string> -i <string> -f <filepath> [-r <filepath>] [-e <string>] [-d <string>] [-q <string>] [--skiplines <integer>] [--trim] [-m <filepath>] [-c <filepath>] [--setnull] [--convertonly] [--concurrencymode <string>] [--assignmentruleid <string>] [-s <integer>] [-w <integer>] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]","pluginName":"@kitalive/sfdx-plugin","pluginType":"core","aliases":[],"examples":["$ sfdx kit:data:bulk:upsert -o Account -f ./path/to/Account.csv -m ./path/to/mapping.json","$ sfdx kit:data:bulk:upsert -o MyObject__c -f ./path/to/MyObject__c.csv -c ./path/to/convert.js -i MyExternalId__c -w 10"],"flags":{"json":{"name":"json","type":"boolean","description":"format output as json","allowNo":false},"loglevel":{"name":"loglevel","type":"option","description":"logging level for this command invocation","required":false,"helpValue":"(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL)","options":["trace","debug","info","warn","error","fatal","TRACE","DEBUG","INFO","WARN","ERROR","FATAL"],"default":"warn"},"targetusername":{"name":"targetusername","type":"option","char":"u","description":"username or alias for the target org; overrides default target org"},"apiversion":{"name":"apiversion","type":"option","description":"override the api version used for api requests made by this command"},"object":{"name":"object","type":"option","char":"o","description":"the sObject name to upsert","required":true},"externalid":{"name":"externalid","type":"option","char":"i","description":"the column name of the external ID","required":true,"default":"Id"},"csvfile":{"name":"csvfile","type":"option","char":"f","description":"the CSV file path that defines the records to upsert","required":true},"resultfile":{"name":"resultfile","type":"option","char":"r","description":"the CSV file path for writing the upsert results"},"encoding":{"name":"encoding","type":"option","char":"e","description":"the input CSV file encoding","default":"utf8"},"delimiter":{"name":"delimiter","type":"option","char":"d","description":"the input CSV file delimiter","default":","},"quote":{"name":"quote","type":"option","char":"q","description":"the input CSV file quote character","default":"\""},"skiplines":{"name":"skiplines","type":"option","description":"the number of lines to skip","default":0},"trim":{"name":"trim","type":"boolean","description":"trim all white space from columns","allowNo":false},"mapping":{"name":"mapping","type":"option","char":"m","description":"the path of the JSON file that defines CSV column mappings"},"converter":{"name":"converter","type":"option","char":"c","description":"the path of the script to convert CSV rows"},"setnull":{"name":"setnull","type":"boolean","description":"set blank values as null values during upsert operations (default: empty field values are ignored)","allowNo":false},"convertonly":{"name":"convertonly","type":"boolean","description":"output converted.csv file and skip upsert for debugging","allowNo":false},"concurrencymode":{"name":"concurrencymode","type":"option","description":"the concurrency mode (Parallel or Serial) for the job","default":"Parallel"},"assignmentruleid":{"name":"assignmentruleid","type":"option","description":"the ID of a specific assignment rule to run for a case or a lead."},"batchsize":{"name":"batchsize","type":"option","char":"s","description":"the batch size of the job","default":10000},"wait":{"name":"wait","type":"option","char":"w","description":"the number of minutes to wait for the command to complete before displaying the results"}},"args":[]},"kit:data:csv:convert":{"id":"kit:data:csv:convert","description":"convert CSV data using column mapping file or Node.js script","usage":"<%= command.id %> [-f <filepath>] [-o <filepath>] [-e <string>] [-d <string>] [-q <string>] [--skiplines <integer>] [--trim] [-m <filepath>] [-c <filepath>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]","pluginName":"@kitalive/sfdx-plugin","pluginType":"core","aliases":[],"examples":["$ sfdx kit:data:csv:convert -f ./path/to/input.csv -m ./path/to/mapping.json","$ sfdx kit:data:csv:convert -f ./path/to/input.csv -o ./path/to/output.csv -c ./path/to/convert.js -e cp932 -d :"],"flags":{"json":{"name":"json","type":"boolean","description":"format output as json","allowNo":false},"loglevel":{"name":"loglevel","type":"option","description":"logging level for this command invocation","required":false,"helpValue":"(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL)","options":["trace","debug","info","warn","error","fatal","TRACE","DEBUG","INFO","WARN","ERROR","FATAL"],"default":"warn"},"inputfile":{"name":"inputfile","type":"option","char":"f","description":"the path of the input CSV file (default: standard input)"},"outputfile":{"name":"outputfile","type":"option","char":"o","description":"the path of the output CSV file (default: standard output)"},"encoding":{"name":"encoding","type":"option","char":"e","description":"the input CSV file encoding","default":"utf8"},"delimiter":{"name":"delimiter","type":"option","char":"d","description":"the input CSV file delimiter","default":","},"quote":{"name":"quote","type":"option","char":"q","description":"the input CSV file quote character","default":"\""},"skiplines":{"name":"skiplines","type":"option","description":"the number of lines to skip","default":0},"trim":{"name":"trim","type":"boolean","description":"trim all white space from columns","allowNo":false},"mapping":{"name":"mapping","type":"option","char":"m","description":"the path of the JSON file that defines CSV column mappings"},"converter":{"name":"converter","type":"option","char":"c","description":"the path of the script to convert CSV rows"}},"args":[]},"kit:layout:assignments:deploy":{"id":"kit:layout:assignments:deploy","description":"deploy page layout assignments from JSON file","usage":"<%= command.id %> -f <string> [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]","pluginName":"@kitalive/sfdx-plugin","pluginType":"core","aliases":[],"examples":["$ sfdx kit:layout:assignments:deploy","$ sfdx kit:layout:assignments:deploy -f config/layout-assignments.scratch.json","$ sfdx kit:layout:assignments:deploy -u me@my.org -f config/layout-assignments.sandbox.json"],"flags":{"json":{"name":"json","type":"boolean","description":"format output as json","allowNo":false},"loglevel":{"name":"loglevel","type":"option","description":"logging level for this command invocation","required":false,"helpValue":"(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL)","options":["trace","debug","info","warn","error","fatal","TRACE","DEBUG","INFO","WARN","ERROR","FATAL"],"default":"warn"},"targetusername":{"name":"targetusername","type":"option","char":"u","description":"username or alias for the target org; overrides default target org"},"apiversion":{"name":"apiversion","type":"option","description":"override the api version used for api requests made by this command"},"file":{"name":"file","type":"option","char":"f","description":"input file path","required":true,"default":"config/layout-assignments.json"}},"args":[]},"kit:layout:assignments:retrieve":{"id":"kit:layout:assignments:retrieve","description":"retrieve page layout assignments and save to JSON file","usage":"<%= command.id %> -f <string> [-p <string>] [-o <string>] [--merge] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]","pluginName":"@kitalive/sfdx-plugin","pluginType":"core","aliases":[],"examples":["$ sfdx kit:layout:assignments:retrieve","$ sfdx kit:layout:assignments:retrieve -p Admin,Standard,StandardAul -o Account,CustomObject__c -f config/layout-assignments.scratch.json","$ sfdx kit:layout:assignments:retrieve -u me@my.org -f config/layout-assignments.sandbox.json"],"flags":{"json":{"name":"json","type":"boolean","description":"format output as json","allowNo":false},"loglevel":{"name":"loglevel","type":"option","description":"logging level for this command invocation","required":false,"helpValue":"(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL)","options":["trace","debug","info","warn","error","fatal","TRACE","DEBUG","INFO","WARN","ERROR","FATAL"],"default":"warn"},"targetusername":{"name":"targetusername","type":"option","char":"u","description":"username or alias for the target org; overrides default target org"},"apiversion":{"name":"apiversion","type":"option","description":"override the api version used for api requests made by this command"},"file":{"name":"file","type":"option","char":"f","description":"output file path","required":true,"default":"config/layout-assignments.json"},"profile":{"name":"profile","type":"option","char":"p","description":"comma separated profile names to retrieve (default: all profiles)","required":false},"object":{"name":"object","type":"option","char":"o","description":"comma separated object names to retrieve (default: objects which have multiple layouts)","required":false},"merge":{"name":"merge","type":"boolean","description":"merge retrieved configurations with existing file","required":false,"allowNo":false}},"args":[]}}}
1
+ {"version":"0.2.0","commands":{"kit:script:execute":{"id":"kit:script:execute","description":"execute Node.js scripts in SfdxCommand context\nAvailable variables in Node.js scripts\n argv: Parsed command line arguments after the file option\n conn: jsforce Connection\n context: SfdxCommand","usage":"<%= command.id %> [-f <filepath>] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]","pluginName":"@kitalive/sfdx-plugin","pluginType":"core","aliases":["kit:script"],"examples":["$ sfdx kit:script -f ./path/to/script.js","$ sfdx kit:script:execute","> await conn.query('SELECT Id, Name FROM Account LIMIT 1')","Top level await is not enabled by default in REPL before Node.js v16","$ NODE_OPTIONS=--experimental-repl-await sfdx kit:script:execute"],"flags":{"json":{"name":"json","type":"boolean","description":"format output as json","allowNo":false},"loglevel":{"name":"loglevel","type":"option","description":"logging level for this command invocation","required":false,"helpValue":"(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL)","options":["trace","debug","info","warn","error","fatal","TRACE","DEBUG","INFO","WARN","ERROR","FATAL"],"default":"warn"},"targetusername":{"name":"targetusername","type":"option","char":"u","description":"username or alias for the target org; overrides default target org"},"apiversion":{"name":"apiversion","type":"option","description":"override the api version used for api requests made by this command"},"file":{"name":"file","type":"option","char":"f","description":"the path of the Node.js script file to execute"}},"args":[]},"kit:data:bulk:delete":{"id":"kit:data:bulk:delete","description":"bulk delete records by SOQL select query","usage":"<%= command.id %> -q <string> [--hard] [--concurrencymode <string>] [-s <integer>] [-w <integer>] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]","pluginName":"@kitalive/sfdx-plugin","pluginType":"core","aliases":[],"examples":["$ sfdx kit:data:bulk:delete -q 'SELECT Id FROM Opportunity WHERE CloseDate < LAST_N_YEARS:5'"],"flags":{"json":{"name":"json","type":"boolean","description":"format output as json","allowNo":false},"loglevel":{"name":"loglevel","type":"option","description":"logging level for this command invocation","required":false,"helpValue":"(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL)","options":["trace","debug","info","warn","error","fatal","TRACE","DEBUG","INFO","WARN","ERROR","FATAL"],"default":"warn"},"targetusername":{"name":"targetusername","type":"option","char":"u","description":"username or alias for the target org; overrides default target org"},"apiversion":{"name":"apiversion","type":"option","description":"override the api version used for api requests made by this command"},"query":{"name":"query","type":"option","char":"q","description":"SOQL query to delete","required":true},"hard":{"name":"hard","type":"boolean","description":"perform a hard delete","allowNo":false},"concurrencymode":{"name":"concurrencymode","type":"option","description":"the concurrency mode (Parallel or Serial) for the job","default":"Parallel"},"batchsize":{"name":"batchsize","type":"option","char":"s","description":"the batch size of the job","default":10000},"wait":{"name":"wait","type":"option","char":"w","description":"the number of minutes to wait for the command to complete before displaying the results"}},"args":[]},"kit:data:bulk:insert":{"id":"kit:data:bulk:insert","description":"bulk insert records from a CSV file\nFor information about CSV file formats, see [Prepare CSV Files](https://developer.salesforce.com/docs/atlas.en-us.api_asynch.meta/api_asynch/datafiles_csv_preparing.htm) in the Bulk API Developer Guide.","usage":"<%= command.id %> -o <string> -f <filepath> [-r <filepath>] [-e <string>] [-d <string>] [-q <string>] [--skiplines <integer>] [--trim] [-m <filepath>] [-c <filepath>] [--setnull] [--convertonly] [--concurrencymode <string>] [--assignmentruleid <string>] [-s <integer>] [-w <integer>] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]","pluginName":"@kitalive/sfdx-plugin","pluginType":"core","aliases":[],"examples":["$ sfdx kit:data:bulk:insert -o Account -f ./path/to/Account.csv -m ./path/to/mapping.json","$ sfdx kit:data:bulk:insert -o MyObject__c -f ./path/to/MyObject__c.csv -c ./path/to/convert.js -w 10"],"flags":{"json":{"name":"json","type":"boolean","description":"format output as json","allowNo":false},"loglevel":{"name":"loglevel","type":"option","description":"logging level for this command invocation","required":false,"helpValue":"(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL)","options":["trace","debug","info","warn","error","fatal","TRACE","DEBUG","INFO","WARN","ERROR","FATAL"],"default":"warn"},"targetusername":{"name":"targetusername","type":"option","char":"u","description":"username or alias for the target org; overrides default target org"},"apiversion":{"name":"apiversion","type":"option","description":"override the api version used for api requests made by this command"},"object":{"name":"object","type":"option","char":"o","description":"the sObject name to insert","required":true},"csvfile":{"name":"csvfile","type":"option","char":"f","description":"the CSV file path that defines the records to insert","required":true},"resultfile":{"name":"resultfile","type":"option","char":"r","description":"the CSV file path for writing the insert results"},"encoding":{"name":"encoding","type":"option","char":"e","description":"the input CSV file encoding","default":"utf8"},"delimiter":{"name":"delimiter","type":"option","char":"d","description":"the input CSV file delimiter","default":","},"quote":{"name":"quote","type":"option","char":"q","description":"the input CSV file quote character","default":"\""},"skiplines":{"name":"skiplines","type":"option","description":"the number of lines to skip","default":0},"trim":{"name":"trim","type":"boolean","description":"trim all white space from columns","allowNo":false},"mapping":{"name":"mapping","type":"option","char":"m","description":"the path of the JSON file that defines CSV column mappings"},"converter":{"name":"converter","type":"option","char":"c","description":"the path of the script to convert CSV rows"},"setnull":{"name":"setnull","type":"boolean","description":"set blank values as null values during insert operations (default: empty field values are ignored)","allowNo":false},"convertonly":{"name":"convertonly","type":"boolean","description":"output converted.csv file and skip insert for debugging","allowNo":false},"concurrencymode":{"name":"concurrencymode","type":"option","description":"the concurrency mode (Parallel or Serial) for the job","default":"Parallel"},"assignmentruleid":{"name":"assignmentruleid","type":"option","description":"the ID of a specific assignment rule to run for a case or a lead."},"batchsize":{"name":"batchsize","type":"option","char":"s","description":"the batch size of the job","default":10000},"wait":{"name":"wait","type":"option","char":"w","description":"the number of minutes to wait for the command to complete before displaying the results"}},"args":[]},"kit:data:bulk:query":{"id":"kit:data:bulk:query","description":"bulk query records","usage":"<%= command.id %> -q <string> [-f <string>] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]","pluginName":"@kitalive/sfdx-plugin","pluginType":"core","aliases":[],"examples":["$ sfdx kit:data:bulk:query -q 'SELECT Id, Name FROM Account' -f ./path/to/Account.csv"],"flags":{"json":{"name":"json","type":"boolean","description":"format output as json","allowNo":false},"loglevel":{"name":"loglevel","type":"option","description":"logging level for this command invocation","required":false,"helpValue":"(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL)","options":["trace","debug","info","warn","error","fatal","TRACE","DEBUG","INFO","WARN","ERROR","FATAL"],"default":"warn"},"targetusername":{"name":"targetusername","type":"option","char":"u","description":"username or alias for the target org; overrides default target org"},"apiversion":{"name":"apiversion","type":"option","description":"override the api version used for api requests made by this command"},"query":{"name":"query","type":"option","char":"q","description":"SOQL query to export","required":true},"csvfile":{"name":"csvfile","type":"option","char":"f","description":"output csv file (default: standard output)"}},"args":[]},"kit:data:bulk:update":{"id":"kit:data:bulk:update","description":"bulk update records from a CSV file\nFor information about CSV file formats, see [Prepare CSV Files](https://developer.salesforce.com/docs/atlas.en-us.api_asynch.meta/api_asynch/datafiles_csv_preparing.htm) in the Bulk API Developer Guide.","usage":"<%= command.id %> -o <string> -f <filepath> [-r <filepath>] [-e <string>] [-d <string>] [-q <string>] [--skiplines <integer>] [--trim] [-m <filepath>] [-c <filepath>] [--setnull] [--convertonly] [--concurrencymode <string>] [--assignmentruleid <string>] [-s <integer>] [-w <integer>] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]","pluginName":"@kitalive/sfdx-plugin","pluginType":"core","aliases":[],"examples":["$ sfdx kit:data:bulk:update -o Account -f ./path/to/Account.csv -m ./path/to/mapping.json","$ sfdx kit:data:bulk:update -o MyObject__c -f ./path/to/MyObject__c.csv -c ./path/to/convert.js -w 10"],"flags":{"json":{"name":"json","type":"boolean","description":"format output as json","allowNo":false},"loglevel":{"name":"loglevel","type":"option","description":"logging level for this command invocation","required":false,"helpValue":"(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL)","options":["trace","debug","info","warn","error","fatal","TRACE","DEBUG","INFO","WARN","ERROR","FATAL"],"default":"warn"},"targetusername":{"name":"targetusername","type":"option","char":"u","description":"username or alias for the target org; overrides default target org"},"apiversion":{"name":"apiversion","type":"option","description":"override the api version used for api requests made by this command"},"object":{"name":"object","type":"option","char":"o","description":"the sObject name to update","required":true},"csvfile":{"name":"csvfile","type":"option","char":"f","description":"the CSV file path that defines the records to update","required":true},"resultfile":{"name":"resultfile","type":"option","char":"r","description":"the CSV file path for writing the update results"},"encoding":{"name":"encoding","type":"option","char":"e","description":"the input CSV file encoding","default":"utf8"},"delimiter":{"name":"delimiter","type":"option","char":"d","description":"the input CSV file delimiter","default":","},"quote":{"name":"quote","type":"option","char":"q","description":"the input CSV file quote character","default":"\""},"skiplines":{"name":"skiplines","type":"option","description":"the number of lines to skip","default":0},"trim":{"name":"trim","type":"boolean","description":"trim all white space from columns","allowNo":false},"mapping":{"name":"mapping","type":"option","char":"m","description":"the path of the JSON file that defines CSV column mappings"},"converter":{"name":"converter","type":"option","char":"c","description":"the path of the script to convert CSV rows"},"setnull":{"name":"setnull","type":"boolean","description":"set blank values as null values during update operations (default: empty field values are ignored)","allowNo":false},"convertonly":{"name":"convertonly","type":"boolean","description":"output converted.csv file and skip update for debugging","allowNo":false},"concurrencymode":{"name":"concurrencymode","type":"option","description":"the concurrency mode (Parallel or Serial) for the job","default":"Parallel"},"assignmentruleid":{"name":"assignmentruleid","type":"option","description":"the ID of a specific assignment rule to run for a case or a lead."},"batchsize":{"name":"batchsize","type":"option","char":"s","description":"the batch size of the job","default":10000},"wait":{"name":"wait","type":"option","char":"w","description":"the number of minutes to wait for the command to complete before displaying the results"}},"args":[]},"kit:data:bulk:upsert":{"id":"kit:data:bulk:upsert","description":"bulk upsert records from a CSV file\nFor information about CSV file formats, see [Prepare CSV Files](https://developer.salesforce.com/docs/atlas.en-us.api_asynch.meta/api_asynch/datafiles_csv_preparing.htm) in the Bulk API Developer Guide.","usage":"<%= command.id %> -o <string> -f <filepath> -i <string> [-r <filepath>] [-e <string>] [-d <string>] [-q <string>] [--skiplines <integer>] [--trim] [-m <filepath>] [-c <filepath>] [--setnull] [--convertonly] [--concurrencymode <string>] [--assignmentruleid <string>] [-s <integer>] [-w <integer>] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]","pluginName":"@kitalive/sfdx-plugin","pluginType":"core","aliases":[],"examples":["$ sfdx kit:data:bulk:upsert -o Account -f ./path/to/Account.csv -m ./path/to/mapping.json","$ sfdx kit:data:bulk:upsert -o MyObject__c -f ./path/to/MyObject__c.csv -c ./path/to/convert.js -i MyExternalId__c -w 10"],"flags":{"json":{"name":"json","type":"boolean","description":"format output as json","allowNo":false},"loglevel":{"name":"loglevel","type":"option","description":"logging level for this command invocation","required":false,"helpValue":"(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL)","options":["trace","debug","info","warn","error","fatal","TRACE","DEBUG","INFO","WARN","ERROR","FATAL"],"default":"warn"},"targetusername":{"name":"targetusername","type":"option","char":"u","description":"username or alias for the target org; overrides default target org"},"apiversion":{"name":"apiversion","type":"option","description":"override the api version used for api requests made by this command"},"object":{"name":"object","type":"option","char":"o","description":"the sObject name to upsert","required":true},"csvfile":{"name":"csvfile","type":"option","char":"f","description":"the CSV file path that defines the records to upsert","required":true},"resultfile":{"name":"resultfile","type":"option","char":"r","description":"the CSV file path for writing the upsert results"},"encoding":{"name":"encoding","type":"option","char":"e","description":"the input CSV file encoding","default":"utf8"},"delimiter":{"name":"delimiter","type":"option","char":"d","description":"the input CSV file delimiter","default":","},"quote":{"name":"quote","type":"option","char":"q","description":"the input CSV file quote character","default":"\""},"skiplines":{"name":"skiplines","type":"option","description":"the number of lines to skip","default":0},"trim":{"name":"trim","type":"boolean","description":"trim all white space from columns","allowNo":false},"mapping":{"name":"mapping","type":"option","char":"m","description":"the path of the JSON file that defines CSV column mappings"},"converter":{"name":"converter","type":"option","char":"c","description":"the path of the script to convert CSV rows"},"setnull":{"name":"setnull","type":"boolean","description":"set blank values as null values during upsert operations (default: empty field values are ignored)","allowNo":false},"convertonly":{"name":"convertonly","type":"boolean","description":"output converted.csv file and skip upsert for debugging","allowNo":false},"concurrencymode":{"name":"concurrencymode","type":"option","description":"the concurrency mode (Parallel or Serial) for the job","default":"Parallel"},"assignmentruleid":{"name":"assignmentruleid","type":"option","description":"the ID of a specific assignment rule to run for a case or a lead."},"batchsize":{"name":"batchsize","type":"option","char":"s","description":"the batch size of the job","default":10000},"wait":{"name":"wait","type":"option","char":"w","description":"the number of minutes to wait for the command to complete before displaying the results"},"externalid":{"name":"externalid","type":"option","char":"i","description":"the column name of the external ID","required":true,"default":"Id"}},"args":[]},"kit:data:csv:convert":{"id":"kit:data:csv:convert","description":"convert CSV data using column mapping file or Node.js script","usage":"<%= command.id %> [-f <filepath>] [-o <filepath>] [-e <string>] [-d <string>] [-q <string>] [--skiplines <integer>] [--trim] [-m <filepath>] [-c <filepath>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]","pluginName":"@kitalive/sfdx-plugin","pluginType":"core","aliases":[],"examples":["$ sfdx kit:data:csv:convert -f ./path/to/input.csv -m ./path/to/mapping.json","$ sfdx kit:data:csv:convert -f ./path/to/input.csv -o ./path/to/output.csv -c ./path/to/convert.js -e cp932 -d :"],"flags":{"json":{"name":"json","type":"boolean","description":"format output as json","allowNo":false},"loglevel":{"name":"loglevel","type":"option","description":"logging level for this command invocation","required":false,"helpValue":"(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL)","options":["trace","debug","info","warn","error","fatal","TRACE","DEBUG","INFO","WARN","ERROR","FATAL"],"default":"warn"},"inputfile":{"name":"inputfile","type":"option","char":"f","description":"the path of the input CSV file (default: standard input)"},"outputfile":{"name":"outputfile","type":"option","char":"o","description":"the path of the output CSV file (default: standard output)"},"encoding":{"name":"encoding","type":"option","char":"e","description":"the input CSV file encoding","default":"utf8"},"delimiter":{"name":"delimiter","type":"option","char":"d","description":"the input CSV file delimiter","default":","},"quote":{"name":"quote","type":"option","char":"q","description":"the input CSV file quote character","default":"\""},"skiplines":{"name":"skiplines","type":"option","description":"the number of lines to skip","default":0},"trim":{"name":"trim","type":"boolean","description":"trim all white space from columns","allowNo":false},"mapping":{"name":"mapping","type":"option","char":"m","description":"the path of the JSON file that defines CSV column mappings"},"converter":{"name":"converter","type":"option","char":"c","description":"the path of the script to convert CSV rows"}},"args":[]},"kit:layout:assignments:deploy":{"id":"kit:layout:assignments:deploy","description":"deploy page layout assignments from JSON file","usage":"<%= command.id %> -f <string> [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]","pluginName":"@kitalive/sfdx-plugin","pluginType":"core","aliases":[],"examples":["$ sfdx kit:layout:assignments:deploy","$ sfdx kit:layout:assignments:deploy -f config/layout-assignments.scratch.json","$ sfdx kit:layout:assignments:deploy -u me@my.org -f config/layout-assignments.sandbox.json"],"flags":{"json":{"name":"json","type":"boolean","description":"format output as json","allowNo":false},"loglevel":{"name":"loglevel","type":"option","description":"logging level for this command invocation","required":false,"helpValue":"(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL)","options":["trace","debug","info","warn","error","fatal","TRACE","DEBUG","INFO","WARN","ERROR","FATAL"],"default":"warn"},"targetusername":{"name":"targetusername","type":"option","char":"u","description":"username or alias for the target org; overrides default target org"},"apiversion":{"name":"apiversion","type":"option","description":"override the api version used for api requests made by this command"},"file":{"name":"file","type":"option","char":"f","description":"input file path","required":true,"default":"config/layout-assignments.json"}},"args":[]},"kit:layout:assignments:retrieve":{"id":"kit:layout:assignments:retrieve","description":"retrieve page layout assignments and save to JSON file","usage":"<%= command.id %> -f <string> [-p <string>] [-o <string>] [--merge] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]","pluginName":"@kitalive/sfdx-plugin","pluginType":"core","aliases":[],"examples":["$ sfdx kit:layout:assignments:retrieve","$ sfdx kit:layout:assignments:retrieve -p Admin,Standard,StandardAul -o Account,CustomObject__c -f config/layout-assignments.scratch.json","$ sfdx kit:layout:assignments:retrieve -u me@my.org -f config/layout-assignments.sandbox.json"],"flags":{"json":{"name":"json","type":"boolean","description":"format output as json","allowNo":false},"loglevel":{"name":"loglevel","type":"option","description":"logging level for this command invocation","required":false,"helpValue":"(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL)","options":["trace","debug","info","warn","error","fatal","TRACE","DEBUG","INFO","WARN","ERROR","FATAL"],"default":"warn"},"targetusername":{"name":"targetusername","type":"option","char":"u","description":"username or alias for the target org; overrides default target org"},"apiversion":{"name":"apiversion","type":"option","description":"override the api version used for api requests made by this command"},"file":{"name":"file","type":"option","char":"f","description":"output file path","required":true,"default":"config/layout-assignments.json"},"profile":{"name":"profile","type":"option","char":"p","description":"comma separated profile names to retrieve (default: all profiles)","required":false},"object":{"name":"object","type":"option","char":"o","description":"comma separated object names to retrieve (default: objects which have multiple layouts)","required":false},"merge":{"name":"merge","type":"boolean","description":"merge retrieved configurations with existing file","required":false,"allowNo":false}},"args":[]}}}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kitalive/sfdx-plugin",
3
3
  "description": "Kitalive SFDX plugin",
4
- "version": "0.1.6",
4
+ "version": "0.2.0",
5
5
  "author": "Akihiro Ono",
6
6
  "bugs": "https://github.com/Kitalive-Inc/sfdx-plugin/issues",
7
7
  "dependencies": {
@@ -15,6 +15,7 @@
15
15
  "fs-extra": "^9.1.0",
16
16
  "iconv-lite": "^0.6.2",
17
17
  "jsforce": "^1.10.1",
18
+ "soql-parser-js": "^4.3.0",
18
19
  "tslib": "^1",
19
20
  "yargs": "^17.3.1"
20
21
  },