@terafina/tffa-sfdx-plugin 15.0.1-rc.0 → 16.0.0-rc.10
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/README.md +298 -18
- package/assets/homepage.html +1 -1
- package/bin/pmd/apex_ruleset.xml +25 -0
- package/lib/commands/tffa/apexdoc.js +1 -1
- package/lib/commands/tffa/apexdoc.js.map +1 -1
- package/lib/commands/tffa/data/export.d.ts +71 -0
- package/lib/commands/tffa/data/export.js +396 -0
- package/lib/commands/tffa/data/export.js.map +1 -0
- package/lib/commands/tffa/data/import.d.ts +69 -0
- package/lib/commands/tffa/data/import.js +291 -0
- package/lib/commands/tffa/data/import.js.map +1 -0
- package/lib/commands/tffa/meta.js +2 -2
- package/lib/commands/tffa/meta.js.map +1 -1
- package/lib/commands/tffa/source/createfield.d.ts +41 -0
- package/lib/commands/tffa/source/createfield.js +210 -0
- package/lib/commands/tffa/source/createfield.js.map +1 -0
- package/lib/services/apexdoc/common/line-reader.js +1 -1
- package/lib/services/apexdoc/common/line-reader.js.map +1 -1
- package/lib/services/apexdoc/engine/generators/models/source-markup-generator.js +12 -1
- package/lib/services/apexdoc/engine/generators/models/source-markup-generator.js.map +1 -1
- package/lib/services/lint/rules.js +2 -2
- package/lib/services/lint/rules.js.map +1 -1
- package/lib/utils/ignored-files.js +2 -0
- package/lib/utils/ignored-files.js.map +1 -1
- package/messages/apexdoc.json +1 -1
- package/messages/createField.js +37 -0
- package/messages/dataExport.js +32 -0
- package/messages/dataImport.js +50 -0
- package/messages/lint.js +31 -0
- package/messages/ping.json +1 -1
- package/oclif.manifest.json +1 -1
- package/package.json +34 -34
- package/yarn.lock +1731 -1786
- package/messages/lint.json +0 -5
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* Copyright (c) NCR Terafina
|
|
5
|
+
**/
|
|
6
|
+
const command_1 = require("@salesforce/command");
|
|
7
|
+
const core_1 = require("@salesforce/core");
|
|
8
|
+
const fs_extra_1 = require("fs-extra");
|
|
9
|
+
const path_1 = require("path");
|
|
10
|
+
// Initialize Messages with the current plugin directory
|
|
11
|
+
core_1.Messages.importMessagesDirectory(__dirname);
|
|
12
|
+
// Load the specific messages for this file. Messages from @salesforce/command, @salesforce/core,
|
|
13
|
+
// or any library that is using the messages framework can also be loaded this way.
|
|
14
|
+
const messages = core_1.Messages.loadMessages('@terafina/tffa-sfdx-plugin', 'dataImport');
|
|
15
|
+
/**
|
|
16
|
+
* Represents a request to perform upsert operation using sfdx bulk2 API
|
|
17
|
+
*/
|
|
18
|
+
class UpsertRequest {
|
|
19
|
+
constructor(object, input, externalIdFieldName) {
|
|
20
|
+
this.object = object;
|
|
21
|
+
this.input = input;
|
|
22
|
+
this.externalIdFieldName = externalIdFieldName;
|
|
23
|
+
this.operation = 'upsert';
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Fields that usually store the external id of records.
|
|
28
|
+
* Fixing them instead of resolving them to save on describe calls.
|
|
29
|
+
*/
|
|
30
|
+
const EXTERNAL_ID_FIELDS = ['tffa__ExternalId__c', 'ExternalId__c', 'tffa__Code__c', 'Code__c'];
|
|
31
|
+
const TFFA_NAMESPACE = 'tffa';
|
|
32
|
+
class DataImport extends command_1.SfdxCommand {
|
|
33
|
+
constructor() {
|
|
34
|
+
super(...arguments);
|
|
35
|
+
this.referenceIdExternalIdMap = new Map();
|
|
36
|
+
this.isScratch = false;
|
|
37
|
+
}
|
|
38
|
+
async run() {
|
|
39
|
+
this.isScratch = await this.org.determineIfScratch();
|
|
40
|
+
this.namespacePrefix = this.org.getConnection().getAuthInfo().getFields().namespacePrefix;
|
|
41
|
+
const sobjectfiles = this.flags.sobjectfiles;
|
|
42
|
+
const plan = this.flags.plan;
|
|
43
|
+
const sobjecttypes = this.flags.sobjecttypes;
|
|
44
|
+
const forceimport = this.flags.forceimport || !!sobjecttypes;
|
|
45
|
+
if (sobjectfiles) {
|
|
46
|
+
for (const sobjectfile of sobjectfiles) {
|
|
47
|
+
const records = (await (0, fs_extra_1.readJSON)(sobjectfile)).records;
|
|
48
|
+
if (records.length) {
|
|
49
|
+
this.collectExternalIds(records);
|
|
50
|
+
await this.upsert(records);
|
|
51
|
+
await this.trackFileChange(sobjectfile);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
else if (plan) {
|
|
56
|
+
let upsertConfigs = (await (0, fs_extra_1.readJSON)(plan));
|
|
57
|
+
if (sobjecttypes) {
|
|
58
|
+
const i = [...upsertConfigs].reverse().findIndex(c => sobjecttypes.includes(c.sobject));
|
|
59
|
+
if (i !== -1) {
|
|
60
|
+
upsertConfigs = upsertConfigs.slice(0, upsertConfigs.length - i);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
const basedir = (0, path_1.dirname)(plan);
|
|
64
|
+
for (const upsertConfig of upsertConfigs) {
|
|
65
|
+
const canUpsert = !sobjecttypes || sobjecttypes.includes(upsertConfig.sobject);
|
|
66
|
+
const allRecords = [];
|
|
67
|
+
const sobjectfiles = [];
|
|
68
|
+
for (const file of upsertConfig.files) {
|
|
69
|
+
const sobjectfile = (0, path_1.join)(basedir, file);
|
|
70
|
+
const records = (await (0, fs_extra_1.readJSON)(sobjectfile)).records;
|
|
71
|
+
this.collectExternalIds(records);
|
|
72
|
+
if (canUpsert && (forceimport || (await this.determineIfFileChanged(sobjectfile)))) {
|
|
73
|
+
allRecords.push(...records);
|
|
74
|
+
sobjectfiles.push(sobjectfile);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
if (canUpsert && allRecords.length) {
|
|
78
|
+
await this.upsert(allRecords);
|
|
79
|
+
await this.trackFileChange(...sobjectfiles);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Gathers external ids from the specified records. The external id of each record along with the external id field name
|
|
86
|
+
* is stored as a lookup reference mapped to the reference id of the record.
|
|
87
|
+
* @see referenceIdExternalIdMap
|
|
88
|
+
* @param records
|
|
89
|
+
*/
|
|
90
|
+
collectExternalIds(records) {
|
|
91
|
+
for (const record of records) {
|
|
92
|
+
for (const externalIdFieldName of this.getExternalIdFieldNames()) {
|
|
93
|
+
const externalId = record[externalIdFieldName];
|
|
94
|
+
if (externalId) {
|
|
95
|
+
this.referenceIdExternalIdMap.set(record.attributes.referenceId, { fieldName: externalIdFieldName, value: externalId });
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
for (const v of Object.values(record)) {
|
|
100
|
+
if (v && typeof v === 'object' && v.records) {
|
|
101
|
+
this.collectExternalIds(v.records);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Upserts the records using sfdx bulk2 API.
|
|
108
|
+
* @param records SObject records
|
|
109
|
+
*/
|
|
110
|
+
async upsert(records) {
|
|
111
|
+
this.ux.startSpinner(`Importing record(s) and relationships of ${records[0].attributes.type}`);
|
|
112
|
+
try {
|
|
113
|
+
const request = this.createUpsertRequest(records);
|
|
114
|
+
await this.execute(request);
|
|
115
|
+
}
|
|
116
|
+
catch (error) {
|
|
117
|
+
this.ux.stopSpinner('error');
|
|
118
|
+
throw error;
|
|
119
|
+
}
|
|
120
|
+
finally {
|
|
121
|
+
this.ux.stopSpinner('done\n');
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Creates an upsert request for the records
|
|
126
|
+
* @param records
|
|
127
|
+
*/
|
|
128
|
+
createUpsertRequest(records) {
|
|
129
|
+
const externalIdFields = this.getExternalIdFieldNames();
|
|
130
|
+
const externalIdFieldName = externalIdFields.find(f => records[0][f]) || externalIdFields[0];
|
|
131
|
+
for (const record of records) {
|
|
132
|
+
const externalId = record[externalIdFieldName];
|
|
133
|
+
if (!externalId) {
|
|
134
|
+
this.ux.log(`ERROR: External id (${externalIdFieldName}) not set for record ${record.attributes.type} ${record.attributes.referenceId}`);
|
|
135
|
+
throw new Error('RECORD_ERROR');
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
const sobjectType = records[0].attributes.type;
|
|
139
|
+
return new UpsertRequest(sobjectType, records, externalIdFieldName);
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Executes the upsert request. May include execution of child upsert requests if the records have child relationships.
|
|
143
|
+
* @param request
|
|
144
|
+
*/
|
|
145
|
+
async execute(request) {
|
|
146
|
+
const describeResult = await this.org.getConnection().describe$(request.object);
|
|
147
|
+
const childrenMap = new Map();
|
|
148
|
+
const fieldSet = new Set();
|
|
149
|
+
for (const record of request.input) {
|
|
150
|
+
for (const field of describeResult.fields) {
|
|
151
|
+
const fvalue = record[field.name];
|
|
152
|
+
if (fvalue === undefined) {
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
if (field.relationshipName && fvalue?.startsWith('@')) {
|
|
156
|
+
const externalId = this.referenceIdExternalIdMap.get(fvalue.slice(1));
|
|
157
|
+
if (!externalId) {
|
|
158
|
+
this.ux.error(`ERROR: Unable to resolve external id for reference id ${fvalue}`);
|
|
159
|
+
throw new Error(`ERROR`);
|
|
160
|
+
}
|
|
161
|
+
const externalIdFQN = `${field.relationshipName}.${externalId.fieldName}`;
|
|
162
|
+
record[externalIdFQN] = externalId.value;
|
|
163
|
+
delete record[field.name];
|
|
164
|
+
fieldSet.add(externalIdFQN);
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
fieldSet.add(field.name);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
for (const childRelationship of describeResult.childRelationships || []) {
|
|
171
|
+
const children = record[childRelationship.relationshipName]?.records;
|
|
172
|
+
if (children) {
|
|
173
|
+
for (const child of children) {
|
|
174
|
+
child[childRelationship.field] = `@${record.attributes.referenceId}`;
|
|
175
|
+
}
|
|
176
|
+
if (!childrenMap.has(childRelationship.childSObject)) {
|
|
177
|
+
childrenMap.set(childRelationship.childSObject, []);
|
|
178
|
+
}
|
|
179
|
+
childrenMap.get(childRelationship.childSObject).push(...children);
|
|
180
|
+
delete record[childRelationship.relationshipName];
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
// bulk API treats the first record in input as the fields definition for the rest of the records
|
|
185
|
+
// as a workaround, we add all the fields seen across all records to the first record
|
|
186
|
+
const first = request.input[0];
|
|
187
|
+
for (const fieldName of fieldSet) {
|
|
188
|
+
if (first[fieldName] === undefined) {
|
|
189
|
+
first[fieldName] = null;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
this.ux.setSpinnerStatus(`importing ${request.input.length} record(s) of ${request.object} using ${request.externalIdFieldName} as external id`);
|
|
193
|
+
const result = await this.org.getConnection().bulk2.loadAndWaitForResults({ ...request, pollTimeout: 1800000 });
|
|
194
|
+
this.logResult(result, request);
|
|
195
|
+
for (const children of childrenMap.values()) {
|
|
196
|
+
await this.execute(this.createUpsertRequest(children));
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Logs the success/error metrics
|
|
201
|
+
* @param result
|
|
202
|
+
* @param request
|
|
203
|
+
*/
|
|
204
|
+
logResult(result, request) {
|
|
205
|
+
if (result.successfulResults?.length) {
|
|
206
|
+
let createdCount = 0;
|
|
207
|
+
let updatedCount = 0;
|
|
208
|
+
for (const successfulResult of result.successfulResults) {
|
|
209
|
+
if (successfulResult.sf__Created === 'true') {
|
|
210
|
+
createdCount++;
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
updatedCount++;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
if (createdCount) {
|
|
217
|
+
this.ux.log(`INFO: Created ${createdCount} record(s) of ${request.object}`);
|
|
218
|
+
}
|
|
219
|
+
if (updatedCount) {
|
|
220
|
+
this.ux.log(`INFO: Updated ${updatedCount} record(s) of ${request.object}`);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
if (result.failedResults?.length) {
|
|
224
|
+
for (const failedResult of result.failedResults) {
|
|
225
|
+
this.ux.error(`ERROR: ${failedResult.sf__Error} id=${failedResult.sf__Id}`);
|
|
226
|
+
}
|
|
227
|
+
throw new Error(`RECORD_ERROR`);
|
|
228
|
+
}
|
|
229
|
+
if (result.unprocessedRecords?.length) {
|
|
230
|
+
throw new Error(`INTERNAL_ERROR`);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Checks if file has changed since the last time it was seen by comparing it's last modified date to last known one.
|
|
235
|
+
* @param sobjectfile
|
|
236
|
+
* @returns
|
|
237
|
+
*/
|
|
238
|
+
async determineIfFileChanged(sobjectfile) {
|
|
239
|
+
if (this.isScratch) {
|
|
240
|
+
const logFile = (0, path_1.join)(this.project.getPath(), '.sf', 'orgs', this.org.getOrgId(), 'tffa', 'dataImport.json');
|
|
241
|
+
const log = (await (0, fs_extra_1.pathExists)(logFile)) && (await (0, fs_extra_1.readJSON)(logFile));
|
|
242
|
+
return !log || !log[sobjectfile] || log[sobjectfile] !== (await (0, fs_extra_1.stat)(sobjectfile)).mtimeMs;
|
|
243
|
+
}
|
|
244
|
+
return true;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Tracks the files for any changes in future. Uses last modified date to track changes.
|
|
248
|
+
* @param sobjectfiles
|
|
249
|
+
*/
|
|
250
|
+
async trackFileChange(...sobjectfiles) {
|
|
251
|
+
if (this.isScratch) {
|
|
252
|
+
const logFile = (0, path_1.join)(this.project.getPath(), '.sf', 'orgs', this.org.getOrgId(), TFFA_NAMESPACE, 'dataImport.json');
|
|
253
|
+
const log = ((await (0, fs_extra_1.pathExists)(logFile)) && (await (0, fs_extra_1.readJSON)(logFile))) || {};
|
|
254
|
+
for (const sobjectfile of sobjectfiles) {
|
|
255
|
+
log[sobjectfile] = (await (0, fs_extra_1.stat)(sobjectfile)).mtimeMs;
|
|
256
|
+
}
|
|
257
|
+
await (0, fs_extra_1.mkdirp)((0, path_1.dirname)(logFile));
|
|
258
|
+
await (0, fs_extra_1.writeJSON)(logFile, log);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Returns the external id field names to be used for:
|
|
263
|
+
* 1. resolving external ids of lookup references on records
|
|
264
|
+
* 2. resolving the external id of records for upsert
|
|
265
|
+
*/
|
|
266
|
+
getExternalIdFieldNames() {
|
|
267
|
+
return this.namespacePrefix && this.namespacePrefix !== TFFA_NAMESPACE && this.namespacePrefix.includes(TFFA_NAMESPACE)
|
|
268
|
+
? EXTERNAL_ID_FIELDS.map(f => f.replace(TFFA_NAMESPACE, this.namespacePrefix))
|
|
269
|
+
: EXTERNAL_ID_FIELDS;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
exports.default = DataImport;
|
|
273
|
+
DataImport.requiresUsername = true;
|
|
274
|
+
DataImport.requiresProject = true;
|
|
275
|
+
DataImport.description = messages.getMessage('commandDescription');
|
|
276
|
+
DataImport.examples = messages.getMessages('commandExamples');
|
|
277
|
+
DataImport.flagsConfig = {
|
|
278
|
+
sobjectfiles: command_1.flags.array({ char: 'f', required: false, description: messages.getMessage('sobjectfilesFlagDescription') }),
|
|
279
|
+
plan: command_1.flags.string({
|
|
280
|
+
char: 'p',
|
|
281
|
+
description: messages.getMessage('planFlagDescription'),
|
|
282
|
+
default: 'data/configuration/config-data-plan.json'
|
|
283
|
+
}),
|
|
284
|
+
sobjecttypes: command_1.flags.array({ char: 's', required: false, description: messages.getMessage('sobjecttypesFlagDescription') }),
|
|
285
|
+
forceimport: command_1.flags.boolean({
|
|
286
|
+
char: 'i',
|
|
287
|
+
required: false,
|
|
288
|
+
description: messages.getMessage('forceimportFlagDescription')
|
|
289
|
+
})
|
|
290
|
+
};
|
|
291
|
+
//# sourceMappingURL=import.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version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AE,QAAQ,CAAC,UAAU,CAAC,6BAA6B,CAAC,EAAE,CAAC;IAC1H,WAAW,EAAE,eAAK,CAAC,OAAO,CAAC;QACzB,IAAI,EAAE,GAAG;QACT,QAAQ,EAAE,KAAK;QACf,WAAW,EAAE,QAAQ,CAAC,UAAU,CAAC,4BAA4B,CAAC;KAC/D,CAAC;CACH,CAAC"}
|
|
@@ -17,8 +17,8 @@ class Meta extends command_1.SfdxCommand {
|
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
exports.default = Meta;
|
|
20
|
-
Meta.description = '
|
|
21
|
-
Meta.examples = [
|
|
20
|
+
Meta.description = 'Scan a sfdx project for generating metadata summary information';
|
|
21
|
+
Meta.examples = ['$ sfdx tffa:meta'];
|
|
22
22
|
Meta.flagsConfig = {
|
|
23
23
|
sourcefolder: command_1.flags.directory({
|
|
24
24
|
char: 's',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meta.js","sourceRoot":"","sources":["../../../src/commands/tffa/meta.ts"],"names":[],"mappings":";AAAA;;IAEI;;;AAEJ,iDAAyD;AACzD,2CAA+C;AAC/C,wFAAuD;AAEvD,MAAqB,IAAK,SAAQ,qBAAW;IA+B3C,8DAA8D;IACvD,KAAK,CAAC,GAAG;QACd,MAAM,kBAAW,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QAEnD,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE;YACrB,IAAI,oBAAS,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;SAC9G;IACH,CAAC;;AAtCH,uBAuCC;AAtCe,gBAAW,GAAG,
|
|
1
|
+
{"version":3,"file":"meta.js","sourceRoot":"","sources":["../../../src/commands/tffa/meta.ts"],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AE,uBAAuB;KACrC,CAAC;CACH,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) NCR Terafina
|
|
3
|
+
**/
|
|
4
|
+
import { SfdxCommand, FlagsConfig } from '@salesforce/command';
|
|
5
|
+
/**
|
|
6
|
+
* Copyright (c) NCR Terafina
|
|
7
|
+
**/
|
|
8
|
+
export default class CreateField extends SfdxCommand {
|
|
9
|
+
static requiresUsername: boolean;
|
|
10
|
+
static requiresProject: boolean;
|
|
11
|
+
static description: string;
|
|
12
|
+
static examples: string[];
|
|
13
|
+
protected static flagsConfig: FlagsConfig;
|
|
14
|
+
private projectdir;
|
|
15
|
+
run(): Promise<any>;
|
|
16
|
+
/**
|
|
17
|
+
* Creates a field definition for the field and writes it to the field-meta xml file.
|
|
18
|
+
* Additional attributes of the field definition are parsed from the flag parameters.
|
|
19
|
+
* @param sObjectType
|
|
20
|
+
* @param fieldName
|
|
21
|
+
*/
|
|
22
|
+
private createField;
|
|
23
|
+
/**
|
|
24
|
+
* Adds a field permission entry for the field to the specified permission sets.
|
|
25
|
+
* @param permissionSets
|
|
26
|
+
* @param sObjectType
|
|
27
|
+
* @param fieldName
|
|
28
|
+
*/
|
|
29
|
+
private addToPermissionSets;
|
|
30
|
+
/**
|
|
31
|
+
* Reads the xml file and returns an xml object
|
|
32
|
+
* @param filename
|
|
33
|
+
*/
|
|
34
|
+
private readXml;
|
|
35
|
+
/**
|
|
36
|
+
* Writes the xml object into the specified file
|
|
37
|
+
* @param filename
|
|
38
|
+
* @param xmlObject
|
|
39
|
+
*/
|
|
40
|
+
private writeXml;
|
|
41
|
+
}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* Copyright (c) NCR Terafina
|
|
5
|
+
**/
|
|
6
|
+
const command_1 = require("@salesforce/command");
|
|
7
|
+
const core_1 = require("@salesforce/core");
|
|
8
|
+
const fs_extra_1 = require("fs-extra");
|
|
9
|
+
const path_1 = require("path");
|
|
10
|
+
const xml2js_1 = require("xml2js");
|
|
11
|
+
// Initialize Messages with the current plugin directory
|
|
12
|
+
core_1.Messages.importMessagesDirectory(__dirname);
|
|
13
|
+
// Load the specific messages for this file. Messages from @salesforce/command, @salesforce/core,
|
|
14
|
+
// or any library that is using the messages framework can also be loaded this way.
|
|
15
|
+
const messages = core_1.Messages.loadMessages('@terafina/tffa-sfdx-plugin', 'createField');
|
|
16
|
+
const STRING_DECAMELIZE_REGEXP = /([a-z\d])([A-Z])/g;
|
|
17
|
+
const STRING_DECAMELIZE_REGEXP2 = /([A-Z])([A-Z][a-z])/g;
|
|
18
|
+
const NON_ALPHANUMERIC_REGEX = /[^a-zA-Z0-9]+/g;
|
|
19
|
+
const CZ_PREFIX = 'CZ';
|
|
20
|
+
const TFFA_NAMESPACE = 'tffa';
|
|
21
|
+
/**
|
|
22
|
+
* Copyright (c) NCR Terafina
|
|
23
|
+
**/
|
|
24
|
+
class CreateField extends command_1.SfdxCommand {
|
|
25
|
+
async run() {
|
|
26
|
+
this.projectdir = (0, path_1.join)(this.project.getDefaultPackage().path, 'main', 'default');
|
|
27
|
+
const name = this.flags.name;
|
|
28
|
+
const sObjectType = this.flags.sobjecttype;
|
|
29
|
+
const required = this.flags.required;
|
|
30
|
+
const permissionSets = this.flags.permissionsets || (await (0, fs_extra_1.readdir)((0, path_1.join)(this.projectdir, 'permissionsets'))).map(f => f.split('.')[0]);
|
|
31
|
+
const simpleName = (name.toLowerCase().endsWith('__c') ? name.slice(0, -3) : name).replace(NON_ALPHANUMERIC_REGEX, '');
|
|
32
|
+
let fieldName = `${simpleName}__c`;
|
|
33
|
+
if (sObjectType.startsWith(TFFA_NAMESPACE) && !fieldName.startsWith(CZ_PREFIX)) {
|
|
34
|
+
fieldName = CZ_PREFIX + fieldName;
|
|
35
|
+
}
|
|
36
|
+
this.ux.startSpinner(`Adding field ${fieldName} to object ${sObjectType}`);
|
|
37
|
+
try {
|
|
38
|
+
await this.createField(sObjectType, fieldName);
|
|
39
|
+
if (!required && permissionSets.length) {
|
|
40
|
+
await this.addToPermissionSets(permissionSets, sObjectType, fieldName);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
this.ux.stopSpinner('error');
|
|
45
|
+
throw error;
|
|
46
|
+
}
|
|
47
|
+
finally {
|
|
48
|
+
this.ux.stopSpinner();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Creates a field definition for the field and writes it to the field-meta xml file.
|
|
53
|
+
* Additional attributes of the field definition are parsed from the flag parameters.
|
|
54
|
+
* @param sObjectType
|
|
55
|
+
* @param fieldName
|
|
56
|
+
*/
|
|
57
|
+
async createField(sObjectType, fieldName) {
|
|
58
|
+
const type = this.flags.type;
|
|
59
|
+
const description = this.flags.description || '';
|
|
60
|
+
const valueSetName = this.flags.valuesetname || '';
|
|
61
|
+
const length = this.flags.length;
|
|
62
|
+
const required = this.flags.required;
|
|
63
|
+
let label = fieldName.slice(0, -3);
|
|
64
|
+
if (label.startsWith(CZ_PREFIX)) {
|
|
65
|
+
label = label.slice(2);
|
|
66
|
+
}
|
|
67
|
+
label = label.replace(STRING_DECAMELIZE_REGEXP, '$1 $2').replace(STRING_DECAMELIZE_REGEXP2, '$1 $2');
|
|
68
|
+
const ftype = type.charAt(0).toUpperCase() + type.slice(1);
|
|
69
|
+
const trackHistory = false;
|
|
70
|
+
const trackTrending = false;
|
|
71
|
+
const field = { fullName: fieldName, description, label, required, trackHistory, trackTrending, type: ftype };
|
|
72
|
+
switch (type) {
|
|
73
|
+
case 'checkbox':
|
|
74
|
+
field.defaultValue = false;
|
|
75
|
+
break;
|
|
76
|
+
case 'currency':
|
|
77
|
+
field.precision = 18;
|
|
78
|
+
field.scale = 2;
|
|
79
|
+
break;
|
|
80
|
+
case 'datetime':
|
|
81
|
+
field.type = 'DateTime';
|
|
82
|
+
break;
|
|
83
|
+
case 'number':
|
|
84
|
+
field.precision = 18;
|
|
85
|
+
field.scale = 0;
|
|
86
|
+
break;
|
|
87
|
+
case 'percent':
|
|
88
|
+
field.precision = 18;
|
|
89
|
+
field.scale = 3;
|
|
90
|
+
break;
|
|
91
|
+
case 'picklist':
|
|
92
|
+
field.valueSet = { restricted: true, valueSetName };
|
|
93
|
+
break;
|
|
94
|
+
case 'picklist-multi':
|
|
95
|
+
field.type = 'MultiselectPicklist';
|
|
96
|
+
field.valueSet = { restricted: true, valueSetName };
|
|
97
|
+
field.visibleLines = 4;
|
|
98
|
+
break;
|
|
99
|
+
case 'text':
|
|
100
|
+
field.caseSensitive = false;
|
|
101
|
+
field.length = length || 255;
|
|
102
|
+
break;
|
|
103
|
+
case 'textarea':
|
|
104
|
+
field.type = 'TextArea';
|
|
105
|
+
break;
|
|
106
|
+
case 'textarea-long':
|
|
107
|
+
field.type = 'LongTextArea';
|
|
108
|
+
field.length = length || 1024;
|
|
109
|
+
field.visibleLines = 3;
|
|
110
|
+
break;
|
|
111
|
+
case 'textarea-rich':
|
|
112
|
+
field.type = 'Html';
|
|
113
|
+
field.length = length || 1024;
|
|
114
|
+
field.visibleLines = 10;
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
this.ux.setSpinnerStatus('creating field-meta xml file');
|
|
118
|
+
// orders the properties in the field alphabetically with fullName placed first
|
|
119
|
+
const field2 = Object.fromEntries(Object.entries(field).sort(([k1], [k2]) => (k1 === 'fullName' ? -1 : k2 === 'fullName' ? 1 : k1.localeCompare(k2))));
|
|
120
|
+
const filename = (0, path_1.join)(this.projectdir, 'objects', sObjectType, 'fields', `${fieldName}.field-meta.xml`);
|
|
121
|
+
await this.writeXml(filename, {
|
|
122
|
+
CustomField: { $: { xmlns: 'http://soap.sforce.com/2006/04/metadata' }, ...field2 }
|
|
123
|
+
});
|
|
124
|
+
this.ux.log(`INFO: Created file - ${filename}`);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Adds a field permission entry for the field to the specified permission sets.
|
|
128
|
+
* @param permissionSets
|
|
129
|
+
* @param sObjectType
|
|
130
|
+
* @param fieldName
|
|
131
|
+
*/
|
|
132
|
+
async addToPermissionSets(permissionSets, sObjectType, fieldName) {
|
|
133
|
+
const field = `${sObjectType}.${fieldName}`;
|
|
134
|
+
const editable = true;
|
|
135
|
+
const readable = true;
|
|
136
|
+
this.ux.setSpinnerStatus('adding field permission to permission sets');
|
|
137
|
+
const fieldPermission = { editable, field, readable };
|
|
138
|
+
for (const permissionSet of permissionSets) {
|
|
139
|
+
if (permissionSet === 'LightningConsole') {
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
const filename = (0, path_1.join)(this.projectdir, 'permissionsets', `${permissionSet}.permissionset-meta.xml`);
|
|
143
|
+
const permissionSetXml = await this.readXml(filename);
|
|
144
|
+
const fieldPermissions = permissionSetXml.PermissionSet.fieldPermissions || (permissionSetXml.PermissionSet.fieldPermissions = []);
|
|
145
|
+
if (!fieldPermissions.some(fp => fp.field[0] === field)) {
|
|
146
|
+
fieldPermissions.push(fieldPermission);
|
|
147
|
+
fieldPermissions.sort((a, b) => (a.field < b.field ? -1 : a.field > b.field ? 1 : 0));
|
|
148
|
+
}
|
|
149
|
+
await this.writeXml(filename, permissionSetXml);
|
|
150
|
+
this.ux.log(`INFO: Added field permission to permission set ${permissionSet}`);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Reads the xml file and returns an xml object
|
|
155
|
+
* @param filename
|
|
156
|
+
*/
|
|
157
|
+
async readXml(filename) {
|
|
158
|
+
return (0, xml2js_1.parseStringPromise)(await (0, fs_extra_1.readFile)(filename));
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Writes the xml object into the specified file
|
|
162
|
+
* @param filename
|
|
163
|
+
* @param xmlObject
|
|
164
|
+
*/
|
|
165
|
+
async writeXml(filename, xmlObject) {
|
|
166
|
+
const xmlString = new xml2js_1.Builder({
|
|
167
|
+
xmldec: { version: '1.0', encoding: 'UTF-8' },
|
|
168
|
+
renderOpts: { pretty: true, indent: ' ' }
|
|
169
|
+
}).buildObject(xmlObject);
|
|
170
|
+
await (0, fs_extra_1.mkdirp)((0, path_1.dirname)(filename));
|
|
171
|
+
await (0, fs_extra_1.writeFile)(filename, xmlString);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
exports.default = CreateField;
|
|
175
|
+
CreateField.requiresUsername = true;
|
|
176
|
+
CreateField.requiresProject = true;
|
|
177
|
+
CreateField.description = messages.getMessage('commandDescription');
|
|
178
|
+
CreateField.examples = messages.getMessages('commandExamples');
|
|
179
|
+
CreateField.flagsConfig = {
|
|
180
|
+
sobjecttype: command_1.flags.string({ char: 's', required: true, description: messages.getMessage('sobjecttypeFlagDescription') }),
|
|
181
|
+
name: command_1.flags.string({ char: 'n', required: true, description: messages.getMessage('nameFlagDescription') }),
|
|
182
|
+
type: command_1.flags.enum({
|
|
183
|
+
char: 't',
|
|
184
|
+
required: true,
|
|
185
|
+
description: messages.getMessage('typeFlagDescription'),
|
|
186
|
+
default: 'text',
|
|
187
|
+
options: [
|
|
188
|
+
'checkbox',
|
|
189
|
+
'currency',
|
|
190
|
+
'date',
|
|
191
|
+
'datetime',
|
|
192
|
+
'email',
|
|
193
|
+
'number',
|
|
194
|
+
'percent',
|
|
195
|
+
'phone',
|
|
196
|
+
'picklist',
|
|
197
|
+
'picklist-multi',
|
|
198
|
+
'text',
|
|
199
|
+
'textarea',
|
|
200
|
+
'textarea-long',
|
|
201
|
+
'textarea-rich'
|
|
202
|
+
]
|
|
203
|
+
}),
|
|
204
|
+
required: command_1.flags.boolean({ char: 'r', required: false, description: messages.getMessage('requiredFlagDescription'), default: false }),
|
|
205
|
+
length: command_1.flags.number({ char: 'l', required: false, description: messages.getMessage('lengthFlagDescription') }),
|
|
206
|
+
description: command_1.flags.string({ char: 'd', required: false, description: messages.getMessage('descriptionFlagDescription') }),
|
|
207
|
+
permissionsets: command_1.flags.array({ char: 'p', required: false, description: messages.getMessage('permissionsetsFlagDescription') }),
|
|
208
|
+
valuesetname: command_1.flags.string({ char: 'v', required: false, description: messages.getMessage('valuesetnameFlagDescription') })
|
|
209
|
+
};
|
|
210
|
+
//# sourceMappingURL=createfield.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createfield.js","sourceRoot":"","sources":["../../../../src/commands/tffa/source/createfield.ts"],"names":[],"mappings":";;AAAA;;IAEI;AACJ,iDAAsE;AACtE,2CAA4C;AAC5C,uCAAgE;AAChE,+BAAqC;AACrC,mCAAqD;AAErD,wDAAwD;AACxD,eAAQ,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC;AAE5C,iGAAiG;AACjG,mFAAmF;AACnF,MAAM,QAAQ,GAAG,eAAQ,CAAC,YAAY,CAAC,4BAA4B,EAAE,aAAa,CAAC,CAAC;AAmCpF,MAAM,wBAAwB,GAAG,mBAAmB,CAAC;AACrD,MAAM,yBAAyB,GAAG,sBAAsB,CAAC;AACzD,MAAM,sBAAsB,GAAG,gBAAgB,CAAC;AAChD,MAAM,SAAS,GAAG,IAAI,CAAC;AACvB,MAAM,cAAc,GAAG,MAAM,CAAC;AAE9B;;IAEI;AACJ,MAAqB,WAAY,SAAQ,qBAAW;IAuClD,KAAK,CAAC,GAAG;QACP,IAAI,CAAC,UAAU,GAAG,IAAA,WAAI,EAAC,IAAI,CAAC,OAAO,CAAC,iBAAiB,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;QAEjF,MAAM,IAAI,GAAW,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;QACrC,MAAM,WAAW,GAAW,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC;QACnD,MAAM,QAAQ,GAAY,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;QAE9C,MAAM,cAAc,GAClB,IAAI,CAAC,KAAK,CAAC,cAAc,IAAI,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AC,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,WAAW,EAAE,QAAQ,CAAC,UAAU,CAAC,yBAAyB,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IACpI,MAAM,EAAE,eAAK,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,WAAW,EAAE,QAAQ,CAAC,UAAU,CAAC,uBAAuB,CAAC,EAAE,CAAC;IAC/G,WAAW,EAAE,eAAK,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,WAAW,EAAE,QAAQ,CAAC,UAAU,CAAC,4BAA4B,CAAC,EAAE,CAAC;IACzH,cAAc,EAAE,eAAK,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,WAAW,EAAE,QAAQ,CAAC,UAAU,CAAC,+BAA+B,CAAC,EAAE,CAAC;IAC9H,YAAY,EAAE,eAAK,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,WAAW,EAAE,QAAQ,CAAC,UAAU,CAAC,6BAA6B,CAAC,EAAE,CAAC;CAC5H,CAAC"}
|
|
@@ -18,7 +18,7 @@ class LineReader {
|
|
|
18
18
|
try {
|
|
19
19
|
// NOTE: could use Node's os.EOL constant instead of the regexp
|
|
20
20
|
// but hesitant because user could have EOL set contrary to the
|
|
21
|
-
// platform they're on in
|
|
21
|
+
// platform they're on in. This might be safer in the end.
|
|
22
22
|
const EOL = /(?:\r\n|[\r\n])/;
|
|
23
23
|
this.content = (0, fs_1.readFileSync)(filePath).toString('utf8');
|
|
24
24
|
this.lines = this.content.split(EOL);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"line-reader.js","sourceRoot":"","sources":["../../../../src/services/apexdoc/common/line-reader.ts"],"names":[],"mappings":";;;A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AAC,GAAG,CAAC,EAAE;YAC1B,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC;SACvC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;OAGG;IACI,YAAY;QACjB,IAAI,IAAI,CAAC,SAAS,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE;YACjC,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC;SACvC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;OAMG;IACI,QAAQ,CAAC,IAAI,GAAG,KAAK,EAAE,SAAS,GAAG,EAAE;QAC1C,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE;YACrB,IAAI,IAAI,EAAE;gBACR,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;aACzD;YAED,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;SACnC;QACD,OAAO,EAAE,CAAC;IACZ,CAAC;IAEM,SAAS;QACd,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAEM,OAAO;QACZ,IAAI,IAAI,CAAC,KAAK,EAAE;YACd,OAAO,IAAI,CAAC,KAAK,CAAC;SACnB;QAED,OAAO,EAAE,CAAC;IACZ,CAAC;CACF;AAED,kBAAe,UAAU,CAAC"}
|
|
@@ -19,14 +19,25 @@ class SourceMarkupGenerator extends markup_generator_1.default {
|
|
|
19
19
|
return '';
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
|
-
|
|
22
|
+
let source = model.source;
|
|
23
23
|
if (model.groupName === 'Pages') {
|
|
24
|
+
source = source.replace(/</g, '<').replace(/>/g, '>');
|
|
24
25
|
markup = `<div class="subsection code">
|
|
25
26
|
<h3 class="subsection-title code">${model.name} Code</h3>
|
|
26
27
|
<pre class="code-example"><code class="language-xml">${source}</code></pre>
|
|
27
28
|
</div>`;
|
|
28
29
|
}
|
|
29
30
|
else {
|
|
31
|
+
const NS = 'tffa';
|
|
32
|
+
const classNames = new Set(Array.from(models.values()).map(p => p.name));
|
|
33
|
+
const className = model.name;
|
|
34
|
+
source = source.replace(/[']?\w+__[cr][']?/g, word => {
|
|
35
|
+
return word.startsWith("'") || word.indexOf('__') !== word.length - 3 ? word : `${NS}__${word}`;
|
|
36
|
+
});
|
|
37
|
+
source = source.replace(/[.'a-z0-9]?[A-Z]\w+/g, word => {
|
|
38
|
+
return !classNames.has(word) || word === className ? word : `${NS}.${word}`;
|
|
39
|
+
});
|
|
40
|
+
source = source.replace(/</g, '<').replace(/>/g, '>');
|
|
30
41
|
markup = `<div class="subsection code">
|
|
31
42
|
<h3 class="subsection-title code">${model.name} Code</h3>
|
|
32
43
|
<pre class="code-example"><code class="language-java">${source}</code></pre>
|