@salesforce/plugin-custom-metadata 1.1.0 → 2.0.1
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/LICENSE.txt +2 -2
- package/README.md +137 -133
- package/lib/commands/force/cmdt/create.d.ts +8 -2
- package/lib/commands/force/cmdt/create.js +15 -21
- package/lib/commands/force/cmdt/create.js.map +1 -1
- package/lib/commands/force/cmdt/field/create.d.ts +7 -2
- package/lib/commands/force/cmdt/field/create.js +15 -20
- package/lib/commands/force/cmdt/field/create.js.map +1 -1
- package/lib/commands/force/cmdt/generate.d.ts +6 -2
- package/lib/commands/force/cmdt/generate.js +79 -150
- package/lib/commands/force/cmdt/generate.js.map +1 -1
- package/lib/commands/force/cmdt/record/create.d.ts +14 -3
- package/lib/commands/force/cmdt/record/create.js +25 -33
- package/lib/commands/force/cmdt/record/create.js.map +1 -1
- package/lib/commands/force/cmdt/record/insert.d.ts +2 -2
- package/lib/commands/force/cmdt/record/insert.js +28 -40
- package/lib/commands/force/cmdt/record/insert.js.map +1 -1
- package/lib/lib/helpers/createUtil.d.ts +10 -6
- package/lib/lib/helpers/createUtil.js +48 -100
- package/lib/lib/helpers/createUtil.js.map +1 -1
- package/lib/lib/helpers/fileWriter.d.ts +11 -11
- package/lib/lib/helpers/fileWriter.js +14 -24
- package/lib/lib/helpers/fileWriter.js.map +1 -1
- package/lib/lib/helpers/metadataUtil.d.ts +25 -51
- package/lib/lib/helpers/metadataUtil.js +55 -131
- package/lib/lib/helpers/metadataUtil.js.map +1 -1
- package/lib/lib/helpers/validationUtil.d.ts +25 -26
- package/lib/lib/helpers/validationUtil.js +66 -43
- package/lib/lib/helpers/validationUtil.js.map +1 -1
- package/lib/lib/interfaces/createConfig.d.ts +3 -2
- package/lib/lib/templates/templates.d.ts +8 -99
- package/lib/lib/templates/templates.js +38 -67
- package/lib/lib/templates/templates.js.map +1 -1
- package/messages/createField.json +22 -31
- package/messages/generate.json +38 -51
- package/messages/template.json +2 -2
- package/messages/validation.json +5 -0
- package/oclif.manifest.json +1 -1
- package/package.json +53 -42
- package/CHANGELOG.md +0 -39
- package/lib/lib/interfaces/customField.d.ts +0 -7
- package/lib/lib/interfaces/customField.js +0 -9
- package/lib/lib/interfaces/customField.js.map +0 -1
- package/lib/lib/interfaces/errorMessage.d.ts +0 -4
- package/lib/lib/interfaces/errorMessage.js +0 -9
- package/lib/lib/interfaces/errorMessage.js.map +0 -1
- package/lib/lib/interfaces/record.d.ts +0 -3
- package/lib/lib/interfaces/record.js +0 -9
- package/lib/lib/interfaces/record.js.map +0 -1
- package/lib/lib/interfaces/saveResults.d.ts +0 -5
- package/lib/lib/interfaces/saveResults.js +0 -9
- package/lib/lib/interfaces/saveResults.js.map +0 -1
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import * as fs from 'fs';
|
|
3
|
+
interface FileWriterResult {
|
|
4
|
+
dir: string;
|
|
5
|
+
fileName: string;
|
|
6
|
+
updated: boolean;
|
|
7
|
+
}
|
|
1
8
|
export declare class FileWriter {
|
|
2
9
|
/**
|
|
3
10
|
* Using the given file system, creates a file representing a new custom metadata type.
|
|
@@ -6,11 +13,7 @@ export declare class FileWriter {
|
|
|
6
13
|
* @param devname
|
|
7
14
|
* @param objectXML
|
|
8
15
|
*/
|
|
9
|
-
writeTypeFile(corefs:
|
|
10
|
-
dir: string;
|
|
11
|
-
fileName: string;
|
|
12
|
-
updated: boolean;
|
|
13
|
-
}>;
|
|
16
|
+
writeTypeFile(corefs: typeof fs, dir: string, devName: string, objectXML: string): Promise<FileWriterResult>;
|
|
14
17
|
/**
|
|
15
18
|
* Using the given file system, creates a file representing a new field for the given custom metadata type
|
|
16
19
|
*
|
|
@@ -18,10 +21,7 @@ export declare class FileWriter {
|
|
|
18
21
|
* @param fieldname
|
|
19
22
|
* @param fieldXML
|
|
20
23
|
*/
|
|
21
|
-
writeFieldFile(corefs:
|
|
22
|
-
dir: string;
|
|
23
|
-
fileName: string;
|
|
24
|
-
updated: boolean;
|
|
25
|
-
}>;
|
|
26
|
-
createDir(dir: any): any;
|
|
24
|
+
writeFieldFile(corefs: typeof fs, dir: string, fieldName: string, fieldXML: string): Promise<FileWriterResult>;
|
|
27
25
|
}
|
|
26
|
+
export declare const removeTrailingSlash: (dir: string) => string;
|
|
27
|
+
export {};
|
|
@@ -6,8 +6,9 @@
|
|
|
6
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
|
-
exports.FileWriter = void 0;
|
|
9
|
+
exports.removeTrailingSlash = exports.FileWriter = void 0;
|
|
10
10
|
const fs = require("fs");
|
|
11
|
+
const path = require("path");
|
|
11
12
|
class FileWriter {
|
|
12
13
|
/**
|
|
13
14
|
* Using the given file system, creates a file representing a new custom metadata type.
|
|
@@ -16,9 +17,8 @@ class FileWriter {
|
|
|
16
17
|
* @param devname
|
|
17
18
|
* @param objectXML
|
|
18
19
|
*/
|
|
19
|
-
async writeTypeFile(corefs, dir, devName, objectXML) {
|
|
20
|
+
async writeTypeFile(corefs = fs, dir, devName, objectXML) {
|
|
20
21
|
let apiName = devName;
|
|
21
|
-
const dirName = this.createDir(dir);
|
|
22
22
|
// replace __c with __mdt
|
|
23
23
|
if (apiName.endsWith('__c')) {
|
|
24
24
|
apiName = apiName.replace('__c', '__mdt');
|
|
@@ -27,11 +27,11 @@ class FileWriter {
|
|
|
27
27
|
if (!apiName.endsWith('__mdt')) {
|
|
28
28
|
apiName += '__mdt';
|
|
29
29
|
}
|
|
30
|
-
const outputFilePath =
|
|
30
|
+
const outputFilePath = path.join((0, exports.removeTrailingSlash)(dir), apiName);
|
|
31
31
|
const fileName = `${apiName}.object-meta.xml`;
|
|
32
|
-
const updated = fs.existsSync(outputFilePath
|
|
33
|
-
await corefs.
|
|
34
|
-
await corefs.writeFile(outputFilePath
|
|
32
|
+
const updated = fs.existsSync(path.join(outputFilePath, fileName));
|
|
33
|
+
await corefs.promises.mkdir(outputFilePath, { recursive: true });
|
|
34
|
+
await corefs.promises.writeFile(path.join(outputFilePath, fileName), objectXML);
|
|
35
35
|
return { dir: outputFilePath, fileName, updated };
|
|
36
36
|
}
|
|
37
37
|
/**
|
|
@@ -42,30 +42,20 @@ class FileWriter {
|
|
|
42
42
|
* @param fieldXML
|
|
43
43
|
*/
|
|
44
44
|
// /fields/{fieldAPI}.field-meta.xml
|
|
45
|
-
async writeFieldFile(corefs, dir, fieldName, fieldXML) {
|
|
46
|
-
const dirName = this.createDir(dir);
|
|
45
|
+
async writeFieldFile(corefs = fs, dir, fieldName, fieldXML) {
|
|
47
46
|
// appending __c if its not already there
|
|
48
47
|
if (fieldName.endsWith('__c') === false) {
|
|
49
48
|
fieldName += '__c';
|
|
50
49
|
}
|
|
51
|
-
const outputFilePath =
|
|
50
|
+
const outputFilePath = path.join((0, exports.removeTrailingSlash)(dir), 'fields');
|
|
52
51
|
const fileName = `${fieldName}.field-meta.xml`;
|
|
53
|
-
const updated = fs.existsSync(outputFilePath
|
|
54
|
-
await corefs.
|
|
55
|
-
await corefs.writeFile(outputFilePath
|
|
52
|
+
const updated = fs.existsSync(path.join(outputFilePath, fileName));
|
|
53
|
+
await corefs.promises.mkdir(outputFilePath, { recursive: true });
|
|
54
|
+
await corefs.promises.writeFile(path.join(outputFilePath, fileName), fieldXML);
|
|
56
55
|
return { dir: outputFilePath, fileName, updated };
|
|
57
56
|
}
|
|
58
|
-
createDir(dir) {
|
|
59
|
-
if (dir) {
|
|
60
|
-
if (dir.endsWith('/')) {
|
|
61
|
-
return dir;
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
return dir + '/';
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
return '';
|
|
68
|
-
}
|
|
69
57
|
}
|
|
70
58
|
exports.FileWriter = FileWriter;
|
|
59
|
+
const removeTrailingSlash = (dir) => dir.replace(/\/+$/, '');
|
|
60
|
+
exports.removeTrailingSlash = removeTrailingSlash;
|
|
71
61
|
//# sourceMappingURL=fileWriter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileWriter.js","sourceRoot":"","sources":["../../../src/lib/helpers/fileWriter.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,yBAAyB;
|
|
1
|
+
{"version":3,"file":"fileWriter.js","sourceRoot":"","sources":["../../../src/lib/helpers/fileWriter.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,yBAAyB;AACzB,6BAA6B;AAQ7B,MAAa,UAAU;IACrB;;;;;;OAMG;IACI,KAAK,CAAC,aAAa,CAAC,MAAM,GAAG,EAAE,EAAE,GAAW,EAAE,OAAe,EAAE,SAAiB;QACrF,IAAI,OAAO,GAAG,OAAO,CAAC;QAEtB,yBAAyB;QACzB,IAAI,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;YAC3B,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;SAC3C;QAED,8CAA8C;QAC9C,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;YAC9B,OAAO,IAAI,OAAO,CAAC;SACpB;QAED,MAAM,cAAc,GAAG,IAAI,CAAC,IAAI,CAAC,IAAA,2BAAmB,EAAC,GAAG,CAAC,EAAE,OAAO,CAAC,CAAC;QACpE,MAAM,QAAQ,GAAG,GAAG,OAAO,kBAAkB,CAAC;QAC9C,MAAM,OAAO,GAAG,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC,CAAC;QAEnE,MAAM,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACjE,MAAM,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC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-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
queryRecords(describeResult: AnyJson): Promise<AnyJson>;
|
|
27
|
-
/**
|
|
28
|
-
* Returns describe object for the field API name from the Object API name you specify
|
|
29
|
-
*
|
|
30
|
-
* @param objDescribe describe object JSON
|
|
31
|
-
* @param fieldName API name of the field to query
|
|
32
|
-
* @returns Promise - Promise - record in JSON format
|
|
33
|
-
*/
|
|
34
|
-
describeField(objDescribe: AnyJson, fieldName: string): AnyJson;
|
|
35
|
-
/**
|
|
36
|
-
* Returns describe object for all fields from the object API name you specify
|
|
37
|
-
*
|
|
38
|
-
* @param objDescribe object describe JSON
|
|
39
|
-
* @returns Promise - Promise - record in JSON format
|
|
40
|
-
*/
|
|
41
|
-
describeObjFields(objDescribe: AnyJson): AnyJson;
|
|
42
|
-
/**
|
|
43
|
-
* Returns true if the object name you specify is a list type custom setting
|
|
44
|
-
*
|
|
45
|
-
* @param objName API name of the object to query
|
|
46
|
-
* @returns boolean
|
|
47
|
-
*/
|
|
48
|
-
validCustomSettingType(objDescribe: AnyJson): boolean;
|
|
49
|
-
cleanQueryResponse(sObjecRecord: AnyJson, objectDescribe: AnyJson): import("@salesforce/ts-types").JsonMap;
|
|
50
|
-
private _getSoqlQuery;
|
|
51
|
-
}
|
|
1
|
+
import { CustomObject, CustomField } from 'jsforce/api/metadata';
|
|
2
|
+
import { Record } from 'jsforce';
|
|
3
|
+
/**
|
|
4
|
+
* Returns describe object for the field API name from the Object API name you specify
|
|
5
|
+
*
|
|
6
|
+
* @param objDescribe describe object JSON
|
|
7
|
+
* @param fieldName API name of the field to query
|
|
8
|
+
* @returns Promise - Promise - record in JSON format
|
|
9
|
+
*/
|
|
10
|
+
export declare const describeField: (objDescribe: CustomObject, fieldName: string) => CustomField;
|
|
11
|
+
/**
|
|
12
|
+
* Returns true if the object name you specify is a list type custom setting
|
|
13
|
+
*
|
|
14
|
+
* @param objName object describe JSON
|
|
15
|
+
* @returns boolean
|
|
16
|
+
*/
|
|
17
|
+
export declare const validCustomSettingType: (objDescribe: CustomObject) => boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Returns describe object for all fields from the object API name you specify
|
|
20
|
+
*
|
|
21
|
+
* @param objDescribe object describe JSON
|
|
22
|
+
* @returns Promise - Promise - record in JSON format
|
|
23
|
+
*/
|
|
24
|
+
export declare const describeObjFields: (objDescribe: CustomObject) => CustomField[];
|
|
25
|
+
export declare const cleanQueryResponse: (sObjectRecord: Record, objectDescribe: CustomObject) => Record;
|
|
@@ -6,136 +6,60 @@
|
|
|
6
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
|
-
exports.
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const query = await this._getSoqlQuery(describeResult['fields'], describeResult['fullName']);
|
|
62
|
-
const queryResult = await this.queryObject(query);
|
|
63
|
-
return (0, ts_types_1.toAnyJson)(queryResult);
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Returns describe object for the field API name from the Object API name you specify
|
|
67
|
-
*
|
|
68
|
-
* @param objDescribe describe object JSON
|
|
69
|
-
* @param fieldName API name of the field to query
|
|
70
|
-
* @returns Promise - Promise - record in JSON format
|
|
71
|
-
*/
|
|
72
|
-
describeField(objDescribe, fieldName) {
|
|
73
|
-
const fieldsDescribe = objDescribe['fields'];
|
|
74
|
-
let fieldsDescribeResult;
|
|
75
|
-
fieldsDescribe.map((field) => {
|
|
76
|
-
if (field.fullName === fieldName) {
|
|
77
|
-
fieldsDescribeResult = field;
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
return fieldsDescribeResult;
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Returns describe object for all fields from the object API name you specify
|
|
84
|
-
*
|
|
85
|
-
* @param objDescribe object describe JSON
|
|
86
|
-
* @returns Promise - Promise - record in JSON format
|
|
87
|
-
*/
|
|
88
|
-
describeObjFields(objDescribe) {
|
|
89
|
-
const fieldsDescribe = objDescribe['fields'];
|
|
90
|
-
return fieldsDescribe;
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Returns true if the object name you specify is a list type custom setting
|
|
94
|
-
*
|
|
95
|
-
* @param objName API name of the object to query
|
|
96
|
-
* @returns boolean
|
|
97
|
-
*/
|
|
98
|
-
validCustomSettingType(objDescribe) {
|
|
99
|
-
if (objDescribe['customSettingsType'] === 'List' &&
|
|
100
|
-
objDescribe['visibility'] === 'Public') {
|
|
101
|
-
return true;
|
|
9
|
+
exports.cleanQueryResponse = exports.describeObjFields = exports.validCustomSettingType = exports.describeField = void 0;
|
|
10
|
+
/**
|
|
11
|
+
* Returns describe object for the field API name from the Object API name you specify
|
|
12
|
+
*
|
|
13
|
+
* @param objDescribe describe object JSON
|
|
14
|
+
* @param fieldName API name of the field to query
|
|
15
|
+
* @returns Promise - Promise - record in JSON format
|
|
16
|
+
*/
|
|
17
|
+
const describeField = (objDescribe, fieldName) => {
|
|
18
|
+
return (0, exports.describeObjFields)(objDescribe).find((field) => field.fullName === fieldName);
|
|
19
|
+
};
|
|
20
|
+
exports.describeField = describeField;
|
|
21
|
+
/**
|
|
22
|
+
* Returns true if the object name you specify is a list type custom setting
|
|
23
|
+
*
|
|
24
|
+
* @param objName object describe JSON
|
|
25
|
+
* @returns boolean
|
|
26
|
+
*/
|
|
27
|
+
const validCustomSettingType = (objDescribe) => objDescribe.customSettingsType === 'List' && objDescribe.visibility === 'Public';
|
|
28
|
+
exports.validCustomSettingType = validCustomSettingType;
|
|
29
|
+
/**
|
|
30
|
+
* Returns describe object for all fields from the object API name you specify
|
|
31
|
+
*
|
|
32
|
+
* @param objDescribe object describe JSON
|
|
33
|
+
* @returns Promise - Promise - record in JSON format
|
|
34
|
+
*/
|
|
35
|
+
const describeObjFields = (objDescribe) => {
|
|
36
|
+
return objDescribe.fields;
|
|
37
|
+
};
|
|
38
|
+
exports.describeObjFields = describeObjFields;
|
|
39
|
+
const cleanQueryResponse = (sObjectRecord, objectDescribe) => {
|
|
40
|
+
return Object.fromEntries(Object.entries(sObjectRecord)
|
|
41
|
+
.filter(([fieldName]) => fieldName !== 'attributes' && fieldName !== 'Name')
|
|
42
|
+
.flatMap(([fieldName, value]) => {
|
|
43
|
+
const fieldDescribe = (0, exports.describeField)(objectDescribe, fieldName);
|
|
44
|
+
// everything but location returns as is
|
|
45
|
+
if (fieldDescribe.type !== 'Location') {
|
|
46
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
47
|
+
return [[fieldName, value]];
|
|
48
|
+
}
|
|
49
|
+
const fieldValue = JSON.stringify(value);
|
|
50
|
+
if (fieldValue.includes('latitude') || fieldValue.includes('longitude')) {
|
|
51
|
+
return [
|
|
52
|
+
[`Lat_${fieldName}`, fieldValue.slice(fieldValue.indexOf(':') + 1, fieldValue.indexOf(','))],
|
|
53
|
+
[`Long_${fieldName}`, fieldValue.slice(fieldValue.lastIndexOf(':') + 1, fieldValue.indexOf('}'))],
|
|
54
|
+
];
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
return [
|
|
58
|
+
[`Lat_${fieldName}`, ''],
|
|
59
|
+
[`Long_${fieldName}`, ''],
|
|
60
|
+
];
|
|
102
61
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
const record = {};
|
|
107
|
-
Object.keys(sObjecRecord).forEach((fieldName) => {
|
|
108
|
-
if (fieldName !== 'attributes' && fieldName !== 'Name') {
|
|
109
|
-
const fieldDescribe = this.describeField(objectDescribe, fieldName);
|
|
110
|
-
const fieldType = fieldDescribe['type'];
|
|
111
|
-
const fieldValue = JSON.stringify(sObjecRecord[fieldName]);
|
|
112
|
-
if (fieldType === 'Location') {
|
|
113
|
-
if (fieldValue.includes('latitude') ||
|
|
114
|
-
fieldValue.includes('longitude')) {
|
|
115
|
-
record['Lat_' + fieldName] = fieldValue.slice(fieldValue.indexOf(':') + 1, fieldValue.indexOf(','));
|
|
116
|
-
record['Long_' + fieldName] = fieldValue.slice(fieldValue.lastIndexOf(':') + 1, fieldValue.indexOf('}'));
|
|
117
|
-
}
|
|
118
|
-
else {
|
|
119
|
-
record['Lat_' + fieldName] = '';
|
|
120
|
-
record['Long_' + fieldName] = '';
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
else {
|
|
124
|
-
record[fieldName] = sObjecRecord[fieldName];
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
return record;
|
|
129
|
-
}
|
|
130
|
-
_getSoqlQuery(arr, objName) {
|
|
131
|
-
const fieldNames = arr
|
|
132
|
-
.map((field) => {
|
|
133
|
-
return field.fullName;
|
|
134
|
-
})
|
|
135
|
-
.join(',');
|
|
136
|
-
// Added Name hardcoded as Name field is not retreived as part of object describe.
|
|
137
|
-
return `SELECT Name, ${fieldNames} FROM ${objName}`;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
exports.MetadataUtil = MetadataUtil;
|
|
62
|
+
}));
|
|
63
|
+
};
|
|
64
|
+
exports.cleanQueryResponse = cleanQueryResponse;
|
|
141
65
|
//# sourceMappingURL=metadataUtil.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metadataUtil.js","sourceRoot":"","sources":["../../../src/lib/helpers/metadataUtil.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;
|
|
1
|
+
{"version":3,"file":"metadataUtil.js","sourceRoot":"","sources":["../../../src/lib/helpers/metadataUtil.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAIH;;;;;;GAMG;AACI,MAAM,aAAa,GAAG,CAAC,WAAyB,EAAE,SAAiB,EAAe,EAAE;IACzF,OAAO,IAAA,yBAAiB,EAAC,WAAW,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC;AACtF,CAAC,CAAC;AAFW,QAAA,aAAa,iBAExB;AAEF;;;;;GAKG;AACI,MAAM,sBAAsB,GAAG,CAAC,WAAyB,EAAW,EAAE,CAC3E,WAAW,CAAC,kBAAkB,KAAK,MAAM,IAAI,WAAW,CAAC,UAAU,KAAK,QAAQ,CAAC;AADtE,QAAA,sBAAsB,0BACgD;AAEnF;;;;;GAKG;AACI,MAAM,iBAAiB,GAAG,CAAC,WAAyB,EAAiB,EAAE;IAC5E,OAAO,WAAW,CAAC,MAAM,CAAC;AAC5B,CAAC,CAAC;AAFW,QAAA,iBAAiB,qBAE5B;AAEK,MAAM,kBAAkB,GAAG,CAAC,aAAqB,EAAE,cAA4B,EAAU,EAAE;IAChG,OAAO,MAAM,CAAC,WAAW,CACvB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|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Returns true if the name is a valid api name for an sobject/field
|
|
3
|
+
*
|
|
4
|
+
* @param name API name of the object
|
|
5
|
+
*/
|
|
6
|
+
export declare const validateAPIName: (name: string, message?: string) => string;
|
|
7
|
+
/**
|
|
8
|
+
* Returns true if the fieldname is a valid metadata object name
|
|
9
|
+
*
|
|
10
|
+
* @param fieldName API name of the field
|
|
11
|
+
*/
|
|
12
|
+
export declare const validateMetadataTypeName: (typeName: string) => string;
|
|
13
|
+
export declare const isValidMetadataRecordName: (recordName: string) => boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Returns true if the fieldname is a valid metadata record name
|
|
16
|
+
*
|
|
17
|
+
* @param fieldName record name of a metadata record
|
|
18
|
+
*/
|
|
19
|
+
export declare const validateMetadataRecordName: (typeName: string) => string;
|
|
20
|
+
/**
|
|
21
|
+
* Returns true if name is below 40 characters
|
|
22
|
+
*
|
|
23
|
+
* @param name label name or plural label
|
|
24
|
+
*/
|
|
25
|
+
export declare const validateLessThanForty: (name: string, message: string) => string;
|
|
@@ -1,55 +1,78 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateLessThanForty = exports.validateMetadataRecordName = exports.isValidMetadataRecordName = exports.validateMetadataTypeName = exports.validateAPIName = void 0;
|
|
2
4
|
/*
|
|
3
5
|
* Copyright (c) 2020, salesforce.com, inc.
|
|
4
6
|
* All rights reserved.
|
|
5
7
|
* Licensed under the BSD 3-Clause license.
|
|
6
8
|
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
7
9
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
10
|
+
const core_1 = require("@salesforce/core");
|
|
11
|
+
core_1.Messages.importMessagesDirectory(__dirname);
|
|
12
|
+
const messages = core_1.Messages.load('@salesforce/plugin-custom-metadata', 'validation', [
|
|
13
|
+
'sobjectnameFlagError',
|
|
14
|
+
'invalidCMDTApiName',
|
|
15
|
+
'notAValidRecordNameError',
|
|
16
|
+
]);
|
|
17
|
+
/**
|
|
18
|
+
* Returns true if the name is a valid api name for an sobject/field
|
|
19
|
+
*
|
|
20
|
+
* @param name API name of the object
|
|
21
|
+
*/
|
|
22
|
+
const validateAPIName = (name, message) => {
|
|
23
|
+
// trimming the __c from the field during character count since it does not count towards the limit
|
|
24
|
+
// Regex makes sure that the field name is alpha numeric, doesn't end in an underscore
|
|
25
|
+
// and optionally if it ends in __c
|
|
26
|
+
const cleanedValue = name.replace('__c', '').replace('__C', '');
|
|
27
|
+
if (cleanedValue.length > 40 || !/^[a-zA-Z][a-zA-Z0-9]*(_[a-zA-Z0-9]+)*(__[cC])?$/.test(cleanedValue)) {
|
|
28
|
+
throw new core_1.SfError(message !== null && message !== void 0 ? message : messages.getMessage('sobjectnameFlagError', [name]));
|
|
22
29
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
return name;
|
|
31
|
+
};
|
|
32
|
+
exports.validateAPIName = validateAPIName;
|
|
33
|
+
/**
|
|
34
|
+
* Returns true if the fieldname is a valid metadata object name
|
|
35
|
+
*
|
|
36
|
+
* @param fieldName API name of the field
|
|
37
|
+
*/
|
|
38
|
+
const validateMetadataTypeName = (typeName) => {
|
|
39
|
+
// trimming the __mdt from the field during character count since it does not count towards the limit
|
|
40
|
+
// Regex makes sure that the field name is alpha numeric, doesn't end in an underscore
|
|
41
|
+
// and optionally if it ends in __mdt
|
|
42
|
+
const trimmedValue = typeName.replace(/__mdt$/gi, '');
|
|
43
|
+
if (trimmedValue.length > 40 || !/^[a-zA-Z][a-zA-Z0-9]*(_[a-zA-Z0-9]+)*(__[mdtT])?$/.test(trimmedValue)) {
|
|
44
|
+
throw new core_1.SfError(messages.getMessage('invalidCMDTApiName', [typeName]));
|
|
34
45
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
46
|
+
return trimmedValue;
|
|
47
|
+
};
|
|
48
|
+
exports.validateMetadataTypeName = validateMetadataTypeName;
|
|
49
|
+
const isValidMetadataRecordName = (recordName) => {
|
|
50
|
+
return recordName.length <= 40 && /^[a-zA-Z][a-zA-Z0-9]*(_[a-zA-Z0-9]+)*$/.test(recordName);
|
|
51
|
+
};
|
|
52
|
+
exports.isValidMetadataRecordName = isValidMetadataRecordName;
|
|
53
|
+
/**
|
|
54
|
+
* Returns true if the fieldname is a valid metadata record name
|
|
55
|
+
*
|
|
56
|
+
* @param fieldName record name of a metadata record
|
|
57
|
+
*/
|
|
58
|
+
const validateMetadataRecordName = (typeName) => {
|
|
59
|
+
// Regex makes sure that the field name is alpha numeric, doesn't end in an underscore
|
|
60
|
+
if (!(0, exports.isValidMetadataRecordName)(typeName)) {
|
|
61
|
+
throw new core_1.SfError(messages.getMessage('notAValidRecordNameError', [typeName]));
|
|
44
62
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
63
|
+
return typeName;
|
|
64
|
+
};
|
|
65
|
+
exports.validateMetadataRecordName = validateMetadataRecordName;
|
|
66
|
+
/**
|
|
67
|
+
* Returns true if name is below 40 characters
|
|
68
|
+
*
|
|
69
|
+
* @param name label name or plural label
|
|
70
|
+
*/
|
|
71
|
+
const validateLessThanForty = (name, message) => {
|
|
72
|
+
if (name.length > 40) {
|
|
73
|
+
throw new core_1.SfError(message);
|
|
52
74
|
}
|
|
53
|
-
|
|
54
|
-
|
|
75
|
+
return name;
|
|
76
|
+
};
|
|
77
|
+
exports.validateLessThanForty = validateLessThanForty;
|
|
55
78
|
//# sourceMappingURL=validationUtil.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validationUtil.js","sourceRoot":"","sources":["../../../src/lib/helpers/validationUtil.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validationUtil.js","sourceRoot":"","sources":["../../../src/lib/helpers/validationUtil.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,2CAAqD;AACrD,eAAQ,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC;AAC5C,MAAM,QAAQ,GAAG,eAAQ,CAAC,IAAI,CAAC,oCAAoC,EAAE,YAAY,EAAE;IACjF,sBAAsB;IACtB,oBAAoB;IACpB,0BAA0B;CAC3B,CAAC,CAAC;AAEH;;;;GAIG;AACI,MAAM,eAAe,GAAG,CAAC,IAAY,EAAE,OAAgB,EAAU,EAAE;IACxE,mGAAmG;IACnG,sFAAsF;IACtF,mCAAmC;IACnC,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAChE,IAAI,YAAY,CAAC,MAAM,GAAG,EAAE,IAAI,CAAC,iDAAiD,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE;QACrG,MAAM,IAAI,cAAO,CAAC,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,QAAQ,CAAC,UAA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EAAE;QACpB,MAAM,IAAI,cAAO,CAAC,OAAO,CAAC,CAAC;KAC5B;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AALW,QAAA,qBAAqB,yBAKhC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Record } from 'jsforce';
|
|
2
|
+
import { CustomField } from 'jsforce/api/metadata';
|
|
2
3
|
export interface CreateConfig {
|
|
3
4
|
typename: string;
|
|
4
5
|
recordname: string;
|
|
@@ -6,7 +7,7 @@ export interface CreateConfig {
|
|
|
6
7
|
inputdir: string;
|
|
7
8
|
outputdir: string;
|
|
8
9
|
protected?: boolean;
|
|
9
|
-
varargs?:
|
|
10
|
+
varargs?: Record;
|
|
10
11
|
fileData?: CustomField[];
|
|
11
12
|
ignorefields?: boolean;
|
|
12
13
|
}
|