@salesforce/plugin-custom-metadata 1.0.10 → 1.1.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.
- package/CHANGELOG.md +16 -0
- package/README.md +96 -43
- package/lib/commands/force/cmdt/create.d.ts +4 -4
- package/lib/commands/force/cmdt/create.js +84 -80
- package/lib/commands/force/cmdt/create.js.map +1 -1
- package/lib/commands/force/cmdt/field/create.d.ts +3 -3
- package/lib/commands/force/cmdt/field/create.js +102 -89
- package/lib/commands/force/cmdt/field/create.js.map +1 -1
- package/lib/commands/force/cmdt/generate.d.ts +6 -6
- package/lib/commands/force/cmdt/generate.js +256 -243
- package/lib/commands/force/cmdt/generate.js.map +1 -1
- package/lib/commands/force/cmdt/record/create.d.ts +6 -6
- package/lib/commands/force/cmdt/record/create.js +130 -124
- package/lib/commands/force/cmdt/record/create.js.map +1 -1
- package/lib/commands/force/cmdt/record/insert.d.ts +5 -5
- package/lib/commands/force/cmdt/record/insert.js +105 -105
- package/lib/commands/force/cmdt/record/insert.js.map +1 -1
- package/lib/index.js +3 -3
- package/lib/lib/helpers/createUtil.js +14 -10
- package/lib/lib/helpers/createUtil.js.map +1 -1
- package/lib/lib/helpers/fileWriter.d.ts +2 -0
- package/lib/lib/helpers/fileWriter.js +5 -3
- package/lib/lib/helpers/fileWriter.js.map +1 -1
- package/lib/lib/helpers/metadataUtil.d.ts +2 -2
- package/lib/lib/helpers/metadataUtil.js +22 -15
- package/lib/lib/helpers/metadataUtil.js.map +1 -1
- package/lib/lib/helpers/validationUtil.js +9 -6
- package/lib/lib/helpers/validationUtil.js.map +1 -1
- package/lib/lib/interfaces/createConfig.js +3 -3
- package/lib/lib/interfaces/customField.js +3 -3
- package/lib/lib/interfaces/errorMessage.js +3 -3
- package/lib/lib/interfaces/record.js +3 -3
- package/lib/lib/interfaces/saveResults.js +3 -3
- package/lib/lib/templates/templates.d.ts +2 -0
- package/lib/lib/templates/templates.js +64 -23
- package/lib/lib/templates/templates.js.map +1 -1
- package/oclif.manifest.json +1 -1
- package/package.json +19 -19
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
* Copyright (c)
|
|
3
|
+
* Copyright (c) 2020, salesforce.com, inc.
|
|
4
4
|
* All rights reserved.
|
|
5
|
-
*
|
|
6
|
-
* For full license text, see
|
|
5
|
+
* Licensed under the BSD 3-Clause license.
|
|
6
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.CreateUtil = void 0;
|
|
10
|
-
const
|
|
10
|
+
const core_1 = require("@salesforce/core");
|
|
11
11
|
const xml2js_1 = require("xml2js");
|
|
12
12
|
const templates_1 = require("../templates/templates");
|
|
13
13
|
// NOTE: the template string indentation is important to output well-formatted XML. Altering that whitespace will change the whitespace of the output.
|
|
@@ -27,7 +27,7 @@ class CreateUtil {
|
|
|
27
27
|
Text: 'string',
|
|
28
28
|
TextArea: 'string',
|
|
29
29
|
LongTextArea: 'string',
|
|
30
|
-
Url: 'string'
|
|
30
|
+
Url: 'string',
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
33
|
/**
|
|
@@ -39,7 +39,7 @@ class CreateUtil {
|
|
|
39
39
|
async createRecord(createConfig) {
|
|
40
40
|
const outputFilePath = `${createConfig.outputdir}/${createConfig.typename}.${createConfig.recordname}.md-meta.xml`;
|
|
41
41
|
const newRecordContent = this.getRecordTemplate(createConfig.label, createConfig.protected, this.buildCustomFieldXml(createConfig.fileData, createConfig.varargs, createConfig.ignorefields));
|
|
42
|
-
return
|
|
42
|
+
return core_1.fs.writeFile(outputFilePath, newRecordContent);
|
|
43
43
|
}
|
|
44
44
|
async getFileData(fieldDirPath, fileNames) {
|
|
45
45
|
const ret = [];
|
|
@@ -48,9 +48,9 @@ class CreateUtil {
|
|
|
48
48
|
let str = '';
|
|
49
49
|
for (const file of fileNames) {
|
|
50
50
|
filePath = `${fieldDirPath}/${file}`;
|
|
51
|
-
fileData = await
|
|
51
|
+
fileData = await core_1.fs.readFile(filePath);
|
|
52
52
|
str = fileData.toString('utf8');
|
|
53
|
-
xml2js_1.parseString(str, (err, res) => {
|
|
53
|
+
(0, xml2js_1.parseString)(str, (err, res) => {
|
|
54
54
|
ret.push(res);
|
|
55
55
|
});
|
|
56
56
|
}
|
|
@@ -167,7 +167,8 @@ class CreateUtil {
|
|
|
167
167
|
* @return {string} int or double
|
|
168
168
|
*/
|
|
169
169
|
getNumberType(type, scale) {
|
|
170
|
-
if (type === 'Number' && parseFloat(scale) === 0 ||
|
|
170
|
+
if ((type === 'Number' && parseFloat(scale) === 0) ||
|
|
171
|
+
(type === 'Percent' && parseFloat(scale) === 0)) {
|
|
171
172
|
return 'int';
|
|
172
173
|
}
|
|
173
174
|
return 'double';
|
|
@@ -183,7 +184,10 @@ class CreateUtil {
|
|
|
183
184
|
getFieldTemplate(fieldName, val, type) {
|
|
184
185
|
// update to handle the null situation
|
|
185
186
|
let value = '';
|
|
186
|
-
const cleanValue = String(val)
|
|
187
|
+
const cleanValue = String(val)
|
|
188
|
+
.replace(/&/g, '&')
|
|
189
|
+
.replace(/</g, '<')
|
|
190
|
+
.replace(/>/g, '>');
|
|
187
191
|
if (val === null || val === '') {
|
|
188
192
|
value = '<value xsi:nil="true"/>';
|
|
189
193
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createUtil.js","sourceRoot":"","sources":["../../../src/lib/helpers/createUtil.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,
|
|
1
|
+
{"version":3,"file":"createUtil.js","sourceRoot":"","sources":["../../../src/lib/helpers/createUtil.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,2CAAsC;AACtC,mCAAqC;AAGrC,sDAAmD;AAEnD,sJAAsJ;AACtJ,MAAa,UAAU;IAGrB;;;OAGG;IAC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+1,7 @@
|
|
|
1
1
|
export declare class FileWriter {
|
|
2
2
|
/**
|
|
3
3
|
* Using the given file system, creates a file representing a new custom metadata type.
|
|
4
|
+
*
|
|
4
5
|
* @param fs
|
|
5
6
|
* @param devname
|
|
6
7
|
* @param objectXML
|
|
@@ -12,6 +13,7 @@ export declare class FileWriter {
|
|
|
12
13
|
}>;
|
|
13
14
|
/**
|
|
14
15
|
* Using the given file system, creates a file representing a new field for the given custom metadata type
|
|
16
|
+
*
|
|
15
17
|
* @param fs
|
|
16
18
|
* @param fieldname
|
|
17
19
|
* @param fieldXML
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
* Copyright (c)
|
|
3
|
+
* Copyright (c) 2020, salesforce.com, inc.
|
|
4
4
|
* All rights reserved.
|
|
5
|
-
*
|
|
6
|
-
* For full license text, see
|
|
5
|
+
* Licensed under the BSD 3-Clause license.
|
|
6
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.FileWriter = void 0;
|
|
@@ -11,6 +11,7 @@ const fs = require("fs");
|
|
|
11
11
|
class FileWriter {
|
|
12
12
|
/**
|
|
13
13
|
* Using the given file system, creates a file representing a new custom metadata type.
|
|
14
|
+
*
|
|
14
15
|
* @param fs
|
|
15
16
|
* @param devname
|
|
16
17
|
* @param objectXML
|
|
@@ -35,6 +36,7 @@ class FileWriter {
|
|
|
35
36
|
}
|
|
36
37
|
/**
|
|
37
38
|
* Using the given file system, creates a file representing a new field for the given custom metadata type
|
|
39
|
+
*
|
|
38
40
|
* @param fs
|
|
39
41
|
* @param fieldname
|
|
40
42
|
* @param fieldXML
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileWriter.js","sourceRoot":"","sources":["../../../src/lib/helpers/fileWriter.ts"],"names":[],"mappings":";AAAA;;;;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C,GAAG,CAAC,CAAC;QAEpC,yCAAyC;QACzC,IAAI,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,KAAK,EAAE;YACvC,SAAS,IAAI,KAAK,CAAC;SACpB;QACD,MAAM,cAAc,GAAG,GAAG,OAAO,SAAS,CAAC;QAC3C,MAAM,QAAQ,GAAG,GAAG,SAAS,iBAAiB,CAAC;QAC/C,MAAM,OAAO,GAAG,EAAE,CAAC,UAAU,CAAC,cAAc,GAAG,QAAQ,CAAC,CAAC;QACzD,MAAM,MAAM,CAAC,MAAM,CAAC,GAAG,OAAO,QAAQ,CAAC,CAAC;QACxC,MAAM,MAAM,CAAC,SAAS,CAAC,cAAc,GAAG,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAE5D,OAAO,EAAE,GAAG,EAAE,cAAc,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpD,CAAC;IAEM,SAAS,CAAC,GAAG;QAClB,IAAI,GAAG,EAAE;YACP,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;gBACrB,OAAO,GAAG,CAAC;aACZ;iBAAM;gBACL,OAAO,GAAG,GAAG,GAAG,CAAC;aAClB;SACF;QACD,OAAO,EAAE,CAAC;IACZ,CAAC;CACF;AAvED,gCAuEC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Connection } from '@salesforce/core';
|
|
2
2
|
import { AnyJson } from '@salesforce/ts-types';
|
|
3
3
|
export declare class MetadataUtil {
|
|
4
4
|
private conn;
|
|
5
|
-
constructor(
|
|
5
|
+
constructor(conn: Connection);
|
|
6
6
|
/**
|
|
7
7
|
* Returns a describe object from the API name you specify
|
|
8
8
|
*
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
* Copyright (c)
|
|
3
|
+
* Copyright (c) 2020, salesforce.com, inc.
|
|
4
4
|
* All rights reserved.
|
|
5
|
-
*
|
|
6
|
-
* For full license text, see
|
|
5
|
+
* Licensed under the BSD 3-Clause license.
|
|
6
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.MetadataUtil = void 0;
|
|
10
10
|
const ts_types_1 = require("@salesforce/ts-types");
|
|
11
11
|
class MetadataUtil {
|
|
12
|
-
constructor(
|
|
13
|
-
this.conn =
|
|
12
|
+
constructor(conn) {
|
|
13
|
+
this.conn = conn;
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
16
|
* Returns a describe object from the API name you specify
|
|
@@ -21,14 +21,17 @@ class MetadataUtil {
|
|
|
21
21
|
async describeObj(objName) {
|
|
22
22
|
const result = await this.conn.metadata.read('CustomObject', objName, (err, meta) => {
|
|
23
23
|
if (err) {
|
|
24
|
-
const errorResponse = {
|
|
24
|
+
const errorResponse = {
|
|
25
|
+
errorCode: '',
|
|
26
|
+
errorMessage: '',
|
|
27
|
+
};
|
|
25
28
|
errorResponse.errorCode = err.name;
|
|
26
29
|
errorResponse.errorMessage = err.message;
|
|
27
30
|
return errorResponse;
|
|
28
31
|
}
|
|
29
32
|
return meta;
|
|
30
33
|
});
|
|
31
|
-
return ts_types_1.toAnyJson(result);
|
|
34
|
+
return (0, ts_types_1.toAnyJson)(result);
|
|
32
35
|
}
|
|
33
36
|
/**
|
|
34
37
|
* Returns an array of object records from a SOQL query
|
|
@@ -46,7 +49,7 @@ class MetadataUtil {
|
|
|
46
49
|
}
|
|
47
50
|
return meta;
|
|
48
51
|
});
|
|
49
|
-
return ts_types_1.toAnyJson(result);
|
|
52
|
+
return (0, ts_types_1.toAnyJson)(result);
|
|
50
53
|
}
|
|
51
54
|
/**
|
|
52
55
|
* Returns an array of object records
|
|
@@ -57,7 +60,7 @@ class MetadataUtil {
|
|
|
57
60
|
async queryRecords(describeResult) {
|
|
58
61
|
const query = await this._getSoqlQuery(describeResult['fields'], describeResult['fullName']);
|
|
59
62
|
const queryResult = await this.queryObject(query);
|
|
60
|
-
return ts_types_1.toAnyJson(queryResult);
|
|
63
|
+
return (0, ts_types_1.toAnyJson)(queryResult);
|
|
61
64
|
}
|
|
62
65
|
/**
|
|
63
66
|
* Returns describe object for the field API name from the Object API name you specify
|
|
@@ -69,7 +72,7 @@ class MetadataUtil {
|
|
|
69
72
|
describeField(objDescribe, fieldName) {
|
|
70
73
|
const fieldsDescribe = objDescribe['fields'];
|
|
71
74
|
let fieldsDescribeResult;
|
|
72
|
-
fieldsDescribe.map(field => {
|
|
75
|
+
fieldsDescribe.map((field) => {
|
|
73
76
|
if (field.fullName === fieldName) {
|
|
74
77
|
fieldsDescribeResult = field;
|
|
75
78
|
}
|
|
@@ -93,20 +96,22 @@ class MetadataUtil {
|
|
|
93
96
|
* @returns boolean
|
|
94
97
|
*/
|
|
95
98
|
validCustomSettingType(objDescribe) {
|
|
96
|
-
if (objDescribe['customSettingsType'] === 'List' &&
|
|
99
|
+
if (objDescribe['customSettingsType'] === 'List' &&
|
|
100
|
+
objDescribe['visibility'] === 'Public') {
|
|
97
101
|
return true;
|
|
98
102
|
}
|
|
99
103
|
return false;
|
|
100
104
|
}
|
|
101
105
|
cleanQueryResponse(sObjecRecord, objectDescribe) {
|
|
102
106
|
const record = {};
|
|
103
|
-
Object.keys(sObjecRecord).forEach(fieldName => {
|
|
107
|
+
Object.keys(sObjecRecord).forEach((fieldName) => {
|
|
104
108
|
if (fieldName !== 'attributes' && fieldName !== 'Name') {
|
|
105
109
|
const fieldDescribe = this.describeField(objectDescribe, fieldName);
|
|
106
110
|
const fieldType = fieldDescribe['type'];
|
|
107
111
|
const fieldValue = JSON.stringify(sObjecRecord[fieldName]);
|
|
108
112
|
if (fieldType === 'Location') {
|
|
109
|
-
if (fieldValue.includes('latitude') ||
|
|
113
|
+
if (fieldValue.includes('latitude') ||
|
|
114
|
+
fieldValue.includes('longitude')) {
|
|
110
115
|
record['Lat_' + fieldName] = fieldValue.slice(fieldValue.indexOf(':') + 1, fieldValue.indexOf(','));
|
|
111
116
|
record['Long_' + fieldName] = fieldValue.slice(fieldValue.lastIndexOf(':') + 1, fieldValue.indexOf('}'));
|
|
112
117
|
}
|
|
@@ -123,9 +128,11 @@ class MetadataUtil {
|
|
|
123
128
|
return record;
|
|
124
129
|
}
|
|
125
130
|
_getSoqlQuery(arr, objName) {
|
|
126
|
-
const fieldNames = arr
|
|
131
|
+
const fieldNames = arr
|
|
132
|
+
.map((field) => {
|
|
127
133
|
return field.fullName;
|
|
128
|
-
})
|
|
134
|
+
})
|
|
135
|
+
.join(',');
|
|
129
136
|
// Added Name hardcoded as Name field is not retreived as part of object describe.
|
|
130
137
|
return `SELECT Name, ${fieldNames} FROM ${objName}`;
|
|
131
138
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metadataUtil.js","sourceRoot":"","sources":["../../../src/lib/helpers/metadataUtil.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAGH,mDAA0D;AAG1D,MAAa,YAAY;
|
|
1
|
+
{"version":3,"file":"metadataUtil.js","sourceRoot":"","sources":["../../../src/lib/helpers/metadataUtil.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAGH,mDAA0D;AAG1D,MAAa,YAAY;IACvB,YAAoB,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAExC;;;;;OAKG;IACI,KAAK,CAAC,WAAW,CAAC,OAAe;QACtC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAC1C,cAAc,EACd,OAAO,EACP,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;YACZ,IAAI,GAAG,EAAE;gBACP,MAAM,aAAa,GAAiB;oBAClC,SAAS,EAAE,EAAE;oBACb,YAAY,EAAE,EAAE;iBACjB,CAAC;gBACF,aAAa,CAAC,SAAS,GAAG,GAAG,CAAC,IAAI,CAAC;gBACn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CAAC,CACxB,CAAC;wBACF,MAAM,CAAC,OAAO,GAAG,SAAS,CAAC,GAAG,UAAU,CAAC,KAAK,CAC5C,UAAU,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,EAC/B,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,CACxB,CAAC;qBACH;yBAAM;wBACL,MAAM,CAAC,MAAM,GAAG,SAAS,CAAC,GAAG,EAAE,CAAC;wBAChC,MAAM,CAAC,OAAO,GAAG,SAAS,CAAC,GAAG,EAAE,CAAC;qBAClC;iBACF;qBAAM;oBACL,MAAM,CAAC,SAAS,CAAC,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC;iBAC7C;aACF;QACH,CAAC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAChB,CAAC;IAEO,aAAa,CAAC,GAAG,EAAE,OAAO;QAChC,MAAM,UAAU,GAAG,GAAG;aACnB,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;YACb,OAAO,KAAK,CAAC,QAAQ,CAAC;QACxB,CAAC,CAAC;aACD,IAAI,CAAC,GAAG,CAAC,CAAC;QACb,kFAAkF;QAClF,OAAO,gBAAgB,UAAU,SAAS,OAAO,EAAE,CAAC;IACtD,CAAC;CACF;AA3JD,oCA2JC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
* Copyright (c)
|
|
3
|
+
* Copyright (c) 2020, salesforce.com, inc.
|
|
4
4
|
* All rights reserved.
|
|
5
|
-
*
|
|
6
|
-
* For full license text, see
|
|
5
|
+
* Licensed under the BSD 3-Clause license.
|
|
6
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.ValidationUtil = void 0;
|
|
@@ -17,7 +17,8 @@ class ValidationUtil {
|
|
|
17
17
|
// trimming the __c from the field during character count since it does not count towards the limit
|
|
18
18
|
// Regex makes sure that the field name is alpha numeric, doesn't end in an underscore
|
|
19
19
|
// and optionally if it ends in __c
|
|
20
|
-
return fieldName.replace('__c', '').replace('__C', '').length <= 40 &&
|
|
20
|
+
return (fieldName.replace('__c', '').replace('__C', '').length <= 40 &&
|
|
21
|
+
/^[a-zA-Z][a-zA-Z0-9]*(_[a-zA-Z0-9]+)*(__[cC])?$/.test(fieldName));
|
|
21
22
|
}
|
|
22
23
|
/**
|
|
23
24
|
* Returns true if the fieldname is a valid metadata object name
|
|
@@ -28,7 +29,8 @@ class ValidationUtil {
|
|
|
28
29
|
// trimming the __mdt from the field during character count since it does not count towards the limit
|
|
29
30
|
// Regex makes sure that the field name is alpha numeric, doesn't end in an underscore
|
|
30
31
|
// and optionally if it ends in __mdt
|
|
31
|
-
return typeName.replace('__mdt', '').length <= 40 &&
|
|
32
|
+
return (typeName.replace('__mdt', '').length <= 40 &&
|
|
33
|
+
/^[a-zA-Z][a-zA-Z0-9]*(_[a-zA-Z0-9]+)*(__mdt)?$/.test(typeName));
|
|
32
34
|
}
|
|
33
35
|
/**
|
|
34
36
|
* Returns true if the fieldname is a valid metadata record name
|
|
@@ -37,7 +39,8 @@ class ValidationUtil {
|
|
|
37
39
|
*/
|
|
38
40
|
validateMetadataRecordName(typeName) {
|
|
39
41
|
// Regex makes sure that the field name is alpha numeric, doesn't end in an underscore
|
|
40
|
-
return typeName.length <= 40 &&
|
|
42
|
+
return (typeName.length <= 40 &&
|
|
43
|
+
/^[a-zA-Z][a-zA-Z0-9]*(_[a-zA-Z0-9]+)*$/.test(typeName));
|
|
41
44
|
}
|
|
42
45
|
/**
|
|
43
46
|
* Returns true if name is below 40 characters
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validationUtil.js","sourceRoot":"","sources":["../../../src/lib/helpers/validationUtil.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,MAAa,cAAc;
|
|
1
|
+
{"version":3,"file":"validationUtil.js","sourceRoot":"","sources":["../../../src/lib/helpers/validationUtil.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,MAAa,cAAc;IACzB;;;;OAIG;IACI,eAAe,CAAC,SAAS;QAC9B,mGAAmG;QACnG,sFAAsF;QACtF,mCAAmC;QACnC,OAAO,CACL,SAAS,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,MAAM,IAAI,EAAE;YAC5D,iDAAiD,CAAC,IAAI,CAAC,SAAS,CAAC,CAClE,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACI,wBAAwB,CAAC,QAAQ;QACtC,qGAAqG;QACrG,sFAAsF;QACtF,qCAAqC;QACrC,OAAO,CACL,QAAQ,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,MAAM,IAAI,EAAE;YAC1C,gDAAgD,CAAC,IAAI,CAAC,QAAQ,CAAC,CAChE,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACI,0BAA0B,CAAC,QAAQ;QACxC,sFAAsF;QACtF,OAAO,CACL,QAAQ,CAAC,MAAM,IAAI,EAAE;YACrB,wCAAwC,CAAC,IAAI,CAAC,QAAQ,CAAC,CACxD,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACI,qBAAqB,CAAC,IAAI;QAC/B,OAAO,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC;IAC3B,CAAC;CACF;AApDD,wCAoDC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
* Copyright (c)
|
|
3
|
+
* Copyright (c) 2020, salesforce.com, inc.
|
|
4
4
|
* All rights reserved.
|
|
5
|
-
*
|
|
6
|
-
* For full license text, see
|
|
5
|
+
* Licensed under the BSD 3-Clause license.
|
|
6
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
//# sourceMappingURL=createConfig.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
* Copyright (c)
|
|
3
|
+
* Copyright (c) 2020, salesforce.com, inc.
|
|
4
4
|
* All rights reserved.
|
|
5
|
-
*
|
|
6
|
-
* For full license text, see
|
|
5
|
+
* Licensed under the BSD 3-Clause license.
|
|
6
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
//# sourceMappingURL=customField.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
* Copyright (c)
|
|
3
|
+
* Copyright (c) 2020, salesforce.com, inc.
|
|
4
4
|
* All rights reserved.
|
|
5
|
-
*
|
|
6
|
-
* For full license text, see
|
|
5
|
+
* Licensed under the BSD 3-Clause license.
|
|
6
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
//# sourceMappingURL=errorMessage.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
* Copyright (c)
|
|
3
|
+
* Copyright (c) 2020, salesforce.com, inc.
|
|
4
4
|
* All rights reserved.
|
|
5
|
-
*
|
|
6
|
-
* For full license text, see
|
|
5
|
+
* Licensed under the BSD 3-Clause license.
|
|
6
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
//# sourceMappingURL=record.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
* Copyright (c)
|
|
3
|
+
* Copyright (c) 2020, salesforce.com, inc.
|
|
4
4
|
* All rights reserved.
|
|
5
|
-
*
|
|
6
|
-
* For full license text, see
|
|
5
|
+
* Licensed under the BSD 3-Clause license.
|
|
6
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
//# sourceMappingURL=saveResults.js.map
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
export declare class Templates {
|
|
2
2
|
/**
|
|
3
3
|
* Using the given data and visibility, creates the body of a type metadata file
|
|
4
|
+
*
|
|
4
5
|
* @param data
|
|
5
6
|
* @param visibility
|
|
6
7
|
*/
|
|
7
8
|
createObjectXML(data: any, visibility: any): string;
|
|
8
9
|
/**
|
|
9
10
|
* Using the given data and defaultToString, creates the body for a field file.
|
|
11
|
+
*
|
|
10
12
|
* @param data Record details
|
|
11
13
|
* @param defaultToString If the defaultToString set type to Text for unsupported field types
|
|
12
14
|
*/
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
* Copyright (c)
|
|
3
|
+
* Copyright (c) 2020, salesforce.com, inc.
|
|
4
4
|
* All rights reserved.
|
|
5
|
-
*
|
|
6
|
-
* For full license text, see
|
|
5
|
+
* Licensed under the BSD 3-Clause license.
|
|
6
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.Templates = void 0;
|
|
@@ -11,12 +11,14 @@ const core_1 = require("@salesforce/core");
|
|
|
11
11
|
class Templates {
|
|
12
12
|
/**
|
|
13
13
|
* Using the given data and visibility, creates the body of a type metadata file
|
|
14
|
+
*
|
|
14
15
|
* @param data
|
|
15
16
|
* @param visibility
|
|
16
17
|
*/
|
|
17
18
|
createObjectXML(data, visibility) {
|
|
18
19
|
let returnValue = '<?xml version="1.0" encoding="UTF-8"?>\n';
|
|
19
|
-
returnValue +=
|
|
20
|
+
returnValue +=
|
|
21
|
+
'<CustomObject xmlns="http://soap.sforce.com/2006/04/metadata">\n';
|
|
20
22
|
returnValue += `\t<label>${data.label}</label>\n`;
|
|
21
23
|
returnValue += `\t<pluralLabel>${data.pluralLabel}</pluralLabel>\n`;
|
|
22
24
|
returnValue += `\t<visibility>${visibility}</visibility>\n`;
|
|
@@ -25,12 +27,14 @@ class Templates {
|
|
|
25
27
|
}
|
|
26
28
|
/**
|
|
27
29
|
* Using the given data and defaultToString, creates the body for a field file.
|
|
30
|
+
*
|
|
28
31
|
* @param data Record details
|
|
29
32
|
* @param defaultToString If the defaultToString set type to Text for unsupported field types
|
|
30
33
|
*/
|
|
31
34
|
createFieldXML(data, defaultToString) {
|
|
32
35
|
let returnValue = '<?xml version="1.0" encoding="UTF-8"?>\n';
|
|
33
|
-
returnValue +=
|
|
36
|
+
returnValue +=
|
|
37
|
+
'<CustomField xmlns="http://soap.sforce.com/2006/04/metadata">\n';
|
|
34
38
|
returnValue += this.getFullName(data);
|
|
35
39
|
returnValue += this.getDescription(data);
|
|
36
40
|
returnValue += this.getExternalId(data);
|
|
@@ -73,13 +77,16 @@ class Templates {
|
|
|
73
77
|
return { fullName, type, label };
|
|
74
78
|
case 'Picklist':
|
|
75
79
|
return {
|
|
76
|
-
fullName,
|
|
80
|
+
fullName,
|
|
81
|
+
type,
|
|
82
|
+
label,
|
|
83
|
+
valueSet: {
|
|
77
84
|
restricted: 'true',
|
|
78
85
|
valueSetDefinition: {
|
|
79
86
|
sorted: 'false',
|
|
80
|
-
value: this.createPicklistValues(picklistValues)
|
|
81
|
-
}
|
|
82
|
-
}
|
|
87
|
+
value: this.createPicklistValues(picklistValues),
|
|
88
|
+
},
|
|
89
|
+
},
|
|
83
90
|
};
|
|
84
91
|
case 'Text':
|
|
85
92
|
return { fullName, type, label, unique: 'false', length: '100' };
|
|
@@ -94,7 +101,20 @@ class Templates {
|
|
|
94
101
|
}
|
|
95
102
|
}
|
|
96
103
|
canConvert(type) {
|
|
97
|
-
const metadataFieldTypes = [
|
|
104
|
+
const metadataFieldTypes = [
|
|
105
|
+
'Checkbox',
|
|
106
|
+
'Date',
|
|
107
|
+
'DateTime',
|
|
108
|
+
'Email',
|
|
109
|
+
'Number',
|
|
110
|
+
'Percent',
|
|
111
|
+
'Phone',
|
|
112
|
+
'Picklist',
|
|
113
|
+
'Text',
|
|
114
|
+
'TextArea',
|
|
115
|
+
'LongTextArea',
|
|
116
|
+
'Url',
|
|
117
|
+
];
|
|
98
118
|
return metadataFieldTypes.includes(type);
|
|
99
119
|
}
|
|
100
120
|
getType(data, defaultToMetadataType) {
|
|
@@ -113,7 +133,9 @@ class Templates {
|
|
|
113
133
|
}
|
|
114
134
|
}
|
|
115
135
|
getConvertType(data) {
|
|
116
|
-
if (data.type === 'Html' ||
|
|
136
|
+
if (data.type === 'Html' ||
|
|
137
|
+
data.type === 'MultiselectPicklist' ||
|
|
138
|
+
(data.type === 'Text' && data.length === undefined)) {
|
|
117
139
|
return 'LongTextArea';
|
|
118
140
|
}
|
|
119
141
|
else {
|
|
@@ -121,20 +143,28 @@ class Templates {
|
|
|
121
143
|
}
|
|
122
144
|
}
|
|
123
145
|
getFullName(data) {
|
|
124
|
-
const name = data.fullName.endsWith('__c')
|
|
146
|
+
const name = data.fullName.endsWith('__c')
|
|
147
|
+
? data.fullName
|
|
148
|
+
: data.fullName + '__c';
|
|
125
149
|
return `\t<fullName>${name}</fullName>\n`;
|
|
126
150
|
}
|
|
127
151
|
getDescription(data) {
|
|
128
|
-
return data.description
|
|
152
|
+
return data.description
|
|
153
|
+
? `\t<description>${data.description}</description>\n`
|
|
154
|
+
: '';
|
|
129
155
|
}
|
|
130
156
|
getExternalId(data) {
|
|
131
|
-
return data.externalId
|
|
157
|
+
return data.externalId
|
|
158
|
+
? `\t<externalId>${data.externalId}</externalId>\n`
|
|
159
|
+
: '';
|
|
132
160
|
}
|
|
133
161
|
getFieldManageability(data) {
|
|
134
162
|
return `\t<fieldManageability>${data.fieldManageability || 'DeveloperControlled'}</fieldManageability>\n`;
|
|
135
163
|
}
|
|
136
164
|
getInlineHelpText(data) {
|
|
137
|
-
return data.inlineHelpText
|
|
165
|
+
return data.inlineHelpText
|
|
166
|
+
? `\t<inlineHelpText>${data.inlineHelpText}</inlineHelpText>\n`
|
|
167
|
+
: '';
|
|
138
168
|
}
|
|
139
169
|
getLabel(data) {
|
|
140
170
|
return `\t<label>${data.label}</label>\n`;
|
|
@@ -146,12 +176,15 @@ class Templates {
|
|
|
146
176
|
return data.precision ? `\t<precision>${data.precision}</precision>\n` : '';
|
|
147
177
|
}
|
|
148
178
|
getScaleTag(data) {
|
|
149
|
-
return typeof data.scale !== 'undefined'
|
|
179
|
+
return typeof data.scale !== 'undefined'
|
|
180
|
+
? `\t<scale>${data.scale}</scale>\n`
|
|
181
|
+
: '';
|
|
150
182
|
}
|
|
151
183
|
getLengthTag(data) {
|
|
152
184
|
// If field type is multiselect or
|
|
153
185
|
// data type is text with no length attribute then it is formula field then set the length to 32768 as we are setting the type LongTextArea
|
|
154
|
-
if (data.type === 'MultiselectPicklist' ||
|
|
186
|
+
if (data.type === 'MultiselectPicklist' ||
|
|
187
|
+
(data.type === 'Text' && data.length === undefined)) {
|
|
155
188
|
return '\t<length>32768</length>\n';
|
|
156
189
|
}
|
|
157
190
|
if (data.length) {
|
|
@@ -160,22 +193,30 @@ class Templates {
|
|
|
160
193
|
// For fields that are being translated from Custom objects that do not have a matching type they are
|
|
161
194
|
// being defaulted to a Text field. They need to have a minimum length to them
|
|
162
195
|
// e.g. Field types that are getting converted: Currency, Location, MasterDetail, Lookup
|
|
163
|
-
return !this.canConvert(data.type) && this.getConvertType(data) === 'Text'
|
|
196
|
+
return !this.canConvert(data.type) && this.getConvertType(data) === 'Text'
|
|
197
|
+
? '\t<length>100</length>\n'
|
|
198
|
+
: '';
|
|
164
199
|
}
|
|
165
200
|
getVisibleLines(data) {
|
|
166
201
|
if (data.type === 'Text' && data.length === undefined) {
|
|
167
202
|
return '\t<visibleLines>3</visibleLines>\n';
|
|
168
203
|
}
|
|
169
|
-
return data.visibleLines
|
|
204
|
+
return data.visibleLines
|
|
205
|
+
? `\t<visibleLines>${data.visibleLines}</visibleLines>\n`
|
|
206
|
+
: '';
|
|
170
207
|
}
|
|
171
208
|
getDefaultValue(data) {
|
|
172
209
|
if (data.type === 'Currency') {
|
|
173
|
-
return data.defaultValue
|
|
210
|
+
return data.defaultValue
|
|
211
|
+
? `\t<defaultValue>'${data.defaultValue}'</defaultValue>\n`
|
|
212
|
+
: '';
|
|
174
213
|
}
|
|
175
214
|
else if (data.type === 'Checkbox' && data.defaultValue === undefined) {
|
|
176
215
|
return '\t<defaultValue>false</defaultValue>\n';
|
|
177
216
|
}
|
|
178
|
-
return data.defaultValue
|
|
217
|
+
return data.defaultValue
|
|
218
|
+
? `\t<defaultValue>${data.defaultValue}</defaultValue>\n`
|
|
219
|
+
: '';
|
|
179
220
|
}
|
|
180
221
|
getValueSet(data) {
|
|
181
222
|
let fieldValue = '';
|
|
@@ -184,7 +225,7 @@ class Templates {
|
|
|
184
225
|
fieldValue += `\t\t<restricted>${data.valueSet.restricted || false}</restricted>\n`;
|
|
185
226
|
fieldValue += '\t\t<valueSetDefinition>\n';
|
|
186
227
|
fieldValue += `\t\t\t<sorted>${data.valueSet.valueSetDefinition.sorted || false}</sorted>\n`;
|
|
187
|
-
data.valueSet.valueSetDefinition.value.forEach(value => {
|
|
228
|
+
data.valueSet.valueSetDefinition.value.forEach((value) => {
|
|
188
229
|
fieldValue += '\t\t\t<value>\n';
|
|
189
230
|
fieldValue += `\t\t\t\t<fullName>${value.fullName}</fullName>\n`;
|
|
190
231
|
fieldValue += `\t\t\t\t<default>${value.default || false}</default>\n`;
|
|
@@ -198,7 +239,7 @@ class Templates {
|
|
|
198
239
|
}
|
|
199
240
|
createPicklistValues(values) {
|
|
200
241
|
const picklistValues = [];
|
|
201
|
-
values.forEach(value => {
|
|
242
|
+
values.forEach((value) => {
|
|
202
243
|
picklistValues.push({ fullName: value, label: value });
|
|
203
244
|
});
|
|
204
245
|
return picklistValues;
|