@salesforce/plugin-sobject 0.0.8

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.
Files changed (48) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/LICENSE.txt +12 -0
  3. package/README.md +282 -0
  4. package/lib/commands/generate/metadata/field.d.ts +25 -0
  5. package/lib/commands/generate/metadata/field.js +242 -0
  6. package/lib/commands/generate/metadata/field.js.map +1 -0
  7. package/lib/commands/generate/metadata/platformevent.d.ts +18 -0
  8. package/lib/commands/generate/metadata/platformevent.js +66 -0
  9. package/lib/commands/generate/metadata/platformevent.js.map +1 -0
  10. package/lib/commands/generate/metadata/sobject.d.ts +19 -0
  11. package/lib/commands/generate/metadata/sobject.js +105 -0
  12. package/lib/commands/generate/metadata/sobject.js.map +1 -0
  13. package/lib/commands/generate/metadata/tab.d.ts +19 -0
  14. package/lib/commands/generate/metadata/tab.js +177 -0
  15. package/lib/commands/generate/metadata/tab.js.map +1 -0
  16. package/lib/index.d.ts +2 -0
  17. package/lib/index.js +9 -0
  18. package/lib/index.js.map +1 -0
  19. package/lib/shared/convert.d.ts +11 -0
  20. package/lib/shared/convert.js +38 -0
  21. package/lib/shared/convert.js.map +1 -0
  22. package/lib/shared/flags.d.ts +15 -0
  23. package/lib/shared/flags.js +58 -0
  24. package/lib/shared/flags.js.map +1 -0
  25. package/lib/shared/fs.d.ts +22 -0
  26. package/lib/shared/fs.js +59 -0
  27. package/lib/shared/fs.js.map +1 -0
  28. package/lib/shared/prompts/prompts.d.ts +28 -0
  29. package/lib/shared/prompts/prompts.js +141 -0
  30. package/lib/shared/prompts/prompts.js.map +1 -0
  31. package/lib/shared/prompts/relationshipField.d.ts +9 -0
  32. package/lib/shared/prompts/relationshipField.js +86 -0
  33. package/lib/shared/prompts/relationshipField.js.map +1 -0
  34. package/lib/shared/types.d.ts +25 -0
  35. package/lib/shared/types.js +9 -0
  36. package/lib/shared/types.js.map +1 -0
  37. package/messages/flags.md +11 -0
  38. package/messages/generate.event.md +21 -0
  39. package/messages/generate.field.md +81 -0
  40. package/messages/generate.object.md +58 -0
  41. package/messages/generate.tab.md +39 -0
  42. package/messages/prompts.relationship.md +27 -0
  43. package/messages/prompts.shared.md +51 -0
  44. package/oclif.manifest.json +1 -0
  45. package/package.json +131 -0
  46. package/schemas/generate-metadata-field.json +59 -0
  47. package/schemas/generate-metadata-sobject.json +85 -0
  48. package/schemas/generate-metadata-tab.json +28 -0
@@ -0,0 +1,28 @@
1
+ import { NamedPackageDir } from '@salesforce/core';
2
+ import { Question, ListQuestion } from 'inquirer';
3
+ import { ValueSet } from 'jsforce/api/metadata';
4
+ export declare const makeNameApiCompatible: (input: string) => string;
5
+ declare type ObjectType = 'CustomObject' | 'PlatformEvent' | 'CustomField';
6
+ export declare const directoryPrompt: (packageDirs: NamedPackageDir[]) => Promise<ListQuestion>;
7
+ export declare const pluralPrompt: (label: string) => Question;
8
+ export declare const apiNamePrompt: (label: string, objectType: ObjectType) => Question;
9
+ export declare const descriptionPrompt: {
10
+ type: string;
11
+ message: string;
12
+ name: string;
13
+ validate: (input: string) => true | string;
14
+ };
15
+ /** Ask about the name/type for the Name field, with a followup for AutoNumber format if AutoNumber is chosen */
16
+ export declare const namePrompts: (label: string) => Array<Question | ListQuestion>;
17
+ /**
18
+ *
19
+ * @param packageDirs
20
+ * @param name The "name" property of the Inquirer answer object. Supports use of the question for multiple scenarios
21
+ */
22
+ export declare const objectPrompt: (packageDirs: NamedPackageDir[], name?: 'object' | 'referenceTo', message?: string) => Promise<ListQuestion>;
23
+ export declare const integerValidation: (value: number, min: number, max: number) => true | string;
24
+ /**
25
+ * recursively keep adding picklist values until the user says to stop
26
+ */
27
+ export declare const picklistPrompts: () => Promise<Omit<ValueSet, 'valueSettings'>>;
28
+ export {};
@@ -0,0 +1,141 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.picklistPrompts = exports.integerValidation = exports.objectPrompt = exports.namePrompts = exports.descriptionPrompt = exports.apiNamePrompt = exports.pluralPrompt = exports.directoryPrompt = exports.makeNameApiCompatible = void 0;
4
+ const inquirer_1 = require("inquirer");
5
+ const core_1 = require("@salesforce/core");
6
+ const fs_1 = require("../fs");
7
+ core_1.Messages.importMessagesDirectory(__dirname);
8
+ const messages = core_1.Messages.load('@salesforce/plugin-sobject', 'prompts.shared', [
9
+ 'directory',
10
+ 'pluralLabel',
11
+ 'apiName',
12
+ 'description',
13
+ 'nameFieldPrompts.autoNumberFormat',
14
+ 'nameFieldPrompts.label',
15
+ 'nameFieldPrompts.type',
16
+ 'object',
17
+ 'picklist.first',
18
+ 'picklist.additional',
19
+ 'numberValidationMin',
20
+ 'numberValidationMax',
21
+ 'error.noDescription',
22
+ ]);
23
+ const makeNameApiCompatible = (input) => input.replace(/ /g, '').replace(/-/g, '_').replace(/_{2,}/g, '_');
24
+ exports.makeNameApiCompatible = makeNameApiCompatible;
25
+ const getSuffix = (objectType) => {
26
+ switch (objectType) {
27
+ case 'CustomObject':
28
+ case 'CustomField':
29
+ return '__c';
30
+ case 'PlatformEvent':
31
+ return '__e';
32
+ }
33
+ };
34
+ const directoryPrompt = async (packageDirs) => ({
35
+ type: 'list',
36
+ message: messages.getMessage('directory'),
37
+ name: 'directory',
38
+ choices: await (0, fs_1.getDirectoriesThatContainObjects)(packageDirs.map((pd) => pd.path)),
39
+ });
40
+ exports.directoryPrompt = directoryPrompt;
41
+ const pluralPrompt = (label) => ({
42
+ type: 'input',
43
+ message: messages.getMessage('pluralLabel'),
44
+ name: 'pluralLabel',
45
+ default: `${label}s`,
46
+ });
47
+ exports.pluralPrompt = pluralPrompt;
48
+ const apiNamePrompt = (label, objectType) => ({
49
+ type: 'input',
50
+ message: messages.getMessage('apiName'),
51
+ name: 'fullName',
52
+ default: `${(0, exports.makeNameApiCompatible)(label)}${getSuffix(objectType)}`,
53
+ });
54
+ exports.apiNamePrompt = apiNamePrompt;
55
+ exports.descriptionPrompt = {
56
+ type: 'input',
57
+ message: messages.getMessage('description'),
58
+ name: 'description',
59
+ validate: (input) => (input.length ? true : messages.getMessage('error.noDescription')),
60
+ };
61
+ /** Ask about the name/type for the Name field, with a followup for AutoNumber format if AutoNumber is chosen */
62
+ const namePrompts = (label) => [
63
+ {
64
+ type: 'input',
65
+ message: messages.getMessage('nameFieldPrompts.label'),
66
+ name: 'nameFieldLabel',
67
+ default: `${label} Name`,
68
+ },
69
+ {
70
+ type: 'list',
71
+ message: messages.getMessage('nameFieldPrompts.type'),
72
+ name: 'nameFieldType',
73
+ default: 'Text',
74
+ choices: ['Text', 'AutoNumber'],
75
+ },
76
+ {
77
+ type: 'input',
78
+ when: (answers) => answers.nameFieldType === 'AutoNumber',
79
+ message: messages.getMessage('nameFieldPrompts.autoNumberFormat'),
80
+ name: 'autoNumberFormat',
81
+ default: `${label}-{0}`,
82
+ },
83
+ ];
84
+ exports.namePrompts = namePrompts;
85
+ /**
86
+ *
87
+ * @param packageDirs
88
+ * @param name The "name" property of the Inquirer answer object. Supports use of the question for multiple scenarios
89
+ */
90
+ const objectPrompt = async (packageDirs, name = 'object', message = messages.getMessage('object')) => ({
91
+ type: 'list',
92
+ message,
93
+ name,
94
+ choices: (await (0, fs_1.getObjectDirectories)(packageDirs.map((pd) => pd.path)))
95
+ .sort()
96
+ .map((objDir) => ({ value: objDir, name: objDir.split('/').pop() })),
97
+ });
98
+ exports.objectPrompt = objectPrompt;
99
+ const integerValidation = (value, min, max) => {
100
+ if (value < min)
101
+ return messages.getMessage('numberValidationMin', [value, min]);
102
+ if (value > max)
103
+ return messages.getMessage('numberValidationMax', [value, max]);
104
+ return true;
105
+ };
106
+ exports.integerValidation = integerValidation;
107
+ /**
108
+ * recursively keep adding picklist values until the user says to stop
109
+ */
110
+ const picklistPrompts = async () => {
111
+ const output = [];
112
+ let keepAsking = true;
113
+ while (keepAsking) {
114
+ // the very definition of needing a loop for an await
115
+ // eslint-disable-next-line no-await-in-loop
116
+ const response = await (0, inquirer_1.prompt)({
117
+ type: 'input',
118
+ name: 'picklistValue',
119
+ validate: (input) => (output.find((v) => v.fullName === input) ? `${input} already exists` : true),
120
+ message: output.length === 0 ? messages.getMessage('picklist.first') : messages.getMessage('picklist.additional'),
121
+ });
122
+ if (response.picklistValue === undefined || response.picklistValue === '') {
123
+ keepAsking = false;
124
+ }
125
+ else {
126
+ output.push({
127
+ fullName: response.picklistValue,
128
+ label: response.picklistValue,
129
+ default: output.length === 0,
130
+ });
131
+ }
132
+ }
133
+ return {
134
+ valueSetDefinition: {
135
+ value: output,
136
+ sorted: true,
137
+ },
138
+ };
139
+ };
140
+ exports.picklistPrompts = picklistPrompts;
141
+ //# sourceMappingURL=prompts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompts.js","sourceRoot":"","sources":["../../../src/shared/prompts/prompts.ts"],"names":[],"mappings":";;;AAOA,uCAA0D;AAE1D,2CAA4C;AAC5C,8BAA+E;AAE/E,eAAQ,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC;AAC5C,MAAM,QAAQ,GAAG,eAAQ,CAAC,IAAI,CAAC,4BAA4B,EAAE,gBAAgB,EAAE;IAC7E,WAAW;IACX,aAAa;IACb,SAAS;IACT,aAAa;IACb,mCAAmC;IACnC,wBAAwB;IACxB,uBAAuB;IACvB,QAAQ;IACR,gBAAgB;IAChB,qBAAqB;IACrB,qBAAqB;IACrB,qBAAqB;IACrB,qBAAqB;CACtB,CAAC,CAAC;AAEI,MAAM,qBAAqB,GAAG,CAAC,KAAa,EAAU,EAAE,CAC7D,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;AADvD,QAAA,qBAAqB,yBACkC;AAGpE,MAAM,SAAS,GAAG,CAAC,UAAsB,EAAU,EAAE;IACnD,QAAQ,UAAU,EAAE;QAClB,KAAK,cAAc,CAAC;QACpB,KAAK,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AC,aAAa,KAAK,EAAE,EAAE;YACzE,UAAU,GAAG,KAAK,CAAC;SACpB;aAAM;YACL,MAAM,CAAC,IAAI,CAAC;gBACV,QAAQ,EAAE,QAAQ,CAAC,aAAa;gBAChC,KAAK,EAAE,QAAQ,CAAC,aAAa;gBAC7B,OAAO,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC;aAC7B,CAAC,CAAC;SACJ;KACF;IAED,OAAO;QACL,kBAAkB,EAAE;YAClB,KAAK,EAAE,MAAM;YACb,MAAM,EAAE,IAAI;SACb;KACF,CAAC;AACJ,CAAC,CAAC;AA/BW,QAAA,eAAe,mBA+B1B"}
@@ -0,0 +1,9 @@
1
+ import { NamedPackageDir } from '@salesforce/core';
2
+ import { CustomField } from 'jsforce/api/metadata';
3
+ declare type RelationshipFieldProperties = Pick<CustomField, 'referenceTo' | 'relationshipLabel' | 'relationshipName' | 'deleteConstraint' | 'reparentableMasterDetail' | 'writeRequiresMasterRead' | 'relationshipOrder'>;
4
+ export declare const relationshipFieldPrompts: ({ type, packageDirs, childObjectFolderPath, }: {
5
+ type: 'MasterDetail' | 'Lookup';
6
+ packageDirs: NamedPackageDir[];
7
+ childObjectFolderPath: string;
8
+ }) => Promise<RelationshipFieldProperties>;
9
+ export {};
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.relationshipFieldPrompts = void 0;
4
+ /*
5
+ * Copyright (c) 2020, salesforce.com, inc.
6
+ * All rights reserved.
7
+ * Licensed under the BSD 3-Clause license.
8
+ * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
9
+ */
10
+ const path = require("path");
11
+ const inquirer_1 = require("inquirer");
12
+ const core_1 = require("@salesforce/core");
13
+ const fs_1 = require("../fs");
14
+ const prompts_1 = require("./prompts");
15
+ core_1.Messages.importMessagesDirectory(__dirname);
16
+ const messages = core_1.Messages.load('@salesforce/plugin-sobject', 'prompts.relationship', [
17
+ 'objectPrompt',
18
+ 'lookupDeleteConstraint',
19
+ 'lookupDeleteConstraint.setNull',
20
+ 'lookupDeleteConstraint.restrict',
21
+ 'lookupDeleteConstraint.cascade',
22
+ 'writeRequiresMasterRead',
23
+ 'reparentableMasterDetail',
24
+ ]);
25
+ const relationshipFieldPrompts = async ({ type, packageDirs, childObjectFolderPath, }) => {
26
+ const childObjectXml = await (0, fs_1.getObjectXmlByFolderAsJson)(childObjectFolderPath);
27
+ const response = await (0, inquirer_1.prompt)([
28
+ // prompt the user to select from objects in local source
29
+ await (0, prompts_1.objectPrompt)(packageDirs, 'referenceTo', messages.getMessage('objectPrompt')),
30
+ {
31
+ type: 'input',
32
+ name: 'relationshipLabel',
33
+ message: 'Relationship label',
34
+ default: childObjectXml.pluralLabel,
35
+ },
36
+ {
37
+ type: 'input',
38
+ name: 'relationshipName',
39
+ message: 'Relationship name',
40
+ default: (answers) => (0, prompts_1.makeNameApiCompatible)(answers.relationshipLabel),
41
+ },
42
+ // lookup-only
43
+ {
44
+ type: 'list',
45
+ name: 'deleteConstraint',
46
+ message: messages.getMessage('lookupDeleteConstraint'),
47
+ when: type === 'Lookup',
48
+ default: 'SetNull',
49
+ choices: [
50
+ {
51
+ value: 'SetNull',
52
+ name: messages.getMessage('lookupDeleteConstraint.setNull'),
53
+ },
54
+ {
55
+ value: 'Restrict',
56
+ name: messages.getMessage('lookupDeleteConstraint.restrict'),
57
+ },
58
+ {
59
+ value: 'Cascade',
60
+ name: messages.getMessage('lookupDeleteConstraint.cascade'),
61
+ },
62
+ ],
63
+ },
64
+ // master-detail only
65
+ {
66
+ type: 'confirm',
67
+ name: 'reparentableMasterDetail',
68
+ message: messages.getMessage('reparentableMasterDetail'),
69
+ when: type === 'MasterDetail',
70
+ default: false,
71
+ },
72
+ {
73
+ type: 'confirm',
74
+ name: 'writeRequiresMasterRead',
75
+ message: messages.getMessage('writeRequiresMasterRead'),
76
+ when: type === 'MasterDetail',
77
+ default: false,
78
+ },
79
+ ]);
80
+ return {
81
+ ...response,
82
+ referenceTo: response.referenceTo.split(path.sep).pop(),
83
+ };
84
+ };
85
+ exports.relationshipFieldPrompts = relationshipFieldPrompts;
86
+ //# sourceMappingURL=relationshipField.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relationshipField.js","sourceRoot":"","sources":["../../../src/shared/prompts/relationshipField.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,6BAA6B;AAE7B,uCAAkC;AAElC,2CAA4C;AAC5C,8BAAmD;AACnD,uCAAgE;AAEhE,eAAQ,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC;AAC5C,MAAM,QAAQ,GAAG,eAAQ,CAAC,IAAI,CAAC,4BAA4B,EAAE,sBAAsB,EAAE;IACnF,cAAc;IACd,wBAAwB;IACxB,gCAAgC;IAChC,iCAAiC;IACjC,gCAAgC;IAChC,yBAAyB;IACzB,0BAA0B;CAC3B,CAAC,CAAC;AAaI,MAAM,wBAAwB,GAAG,KAAK,EAAE,EAC7C,IAAI,EACJ,WAAW,EACX,qBAAqB,GAKtB,EAAwC,EAAE;IACzC,MAAM,cAAc,GAAG,MAAM,IAAA,+BAA0B,EAAC,qBAAqB,CAAC,CAAC;IAC/E,MAAM,QAAQ,GAAG,MAAM,IAAA,iBAAM,EAA8B;QACzD,yDAAyD;QACzD,MAAM,IAAA,sBAAY,EAAC,WAAW,EAAE,aAAa,EAAE,QAAQ,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC;QACnF;YACE,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,mBAAmB;YACzB,OAAO,EAAE,oBAAoB;YAC7B,OAAO,EAAE,cAAc,CAAC,WAAW;SACpC;QACD;YACE,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,kBAAkB;YACxB,OAAO,EAAE,mBAAmB;YAC5B,OAAO,EAAE,CAAC,OAAoC,EAAE,EAAE,CAAC,IAAA,+BAAqB,EAAC,OAAO,CAAC,iBAAiB,CAAC;SACpG;QACD,cAAc;QACd;YACE,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,kBAAkB;YACxB,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,wBAAwB,CAAC;YACtD,IAAI,EAAE,IAAI,KAAK,QAAQ;YACvB,OAAO,EAAE,SAAS;YAClB,OAAO,EAAE;gBACP;oBACE,KAAK,EAAE,SAAS;oBAChB,IAAI,EAAE,QAAQ,CAAC,UAAU,CAAC,gCAAgC,CAAC;iBAC5D;gBACD;oBACE,KAAK,EAAE,UAAU;oBACjB,IAAI,EAAE,QAAQ,CAAC,UAAU,CAAC,iCAAiC,CAAC;iBAC7D;gBACD;oBACE,KAAK,EAAE,SAAS;oBAChB,IAAI,EAAE,QAAQ,CAAC,UAAU,CAAC,gCAAgC,CAAC;iBAC5D;aACF;SACF;QACD,qBAAqB;QACrB;YACE,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,0BAA0B;YAChC,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,0BAA0B,CAAC;YACxD,IAAI,EAAE,IAAI,KAAK,cAAc;YAC7B,OAAO,EAAE,KAAK;SACf;QACD;YACE,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,yBAAyB;YAC/B,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,yBAAyB,CAAC;YACvD,IAAI,EAAE,IAAI,KAAK,cAAc;YAC7B,OAAO,EAAE,KAAK;SACf;KACF,CAAC,CAAC;IAEH,OAAO;QACL,GAAG,QAAQ;QACX,WAAW,EAAE,QAAQ,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE;KACxD,CAAC;AACJ,CAAC,CAAC;AApEW,QAAA,wBAAwB,4BAoEnC"}
@@ -0,0 +1,25 @@
1
+ import { CustomObject, CustomField } from 'jsforce/api/metadata';
2
+ /** Used to capture the types for NameField in the inquirer prompts */
3
+ export declare type NameFieldResponse = {
4
+ nameFieldType: 'Text' | 'AutoNumber';
5
+ nameFieldLabel: 'string';
6
+ autoNumberFormat?: string;
7
+ };
8
+ /** Used by classical CustomObject */
9
+ declare type NameField = Pick<CustomField, 'label' | 'type' | 'displayFormat'>;
10
+ /**
11
+ * There are a lot of properties that we don't, and some that jsforce thinks are mandatory that aren't.
12
+ * Many apply to the various sub-species (mdt, external, events)
13
+ *
14
+ * This type represents a PlatformEvent that can deploy.
15
+ */ export declare type SaveablePlatformEvent = Pick<CustomObject, 'fullName' | 'label' | 'deploymentStatus' | 'description' | 'pluralLabel' | 'eventType' | 'publishBehavior'>;
16
+ /**
17
+ * There are a lot of properties that we don't, and some that jsforce thinks are mandatory that aren't.
18
+ * Many apply to the various sub-species (mdt, external, events)
19
+ *
20
+ * This type represents a "classical" CustomObject subset that can deploy.
21
+ */
22
+ export declare type SaveableCustomObject = Pick<CustomObject, 'label' | 'deploymentStatus' | 'description' | 'enableHistory' | 'enableActivities' | 'enableBulkApi' | 'enableFeeds' | 'enableReports' | 'enableSearch' | 'enableStreamingApi' | 'enableSharing' | 'pluralLabel' | 'sharingModel' | 'fullName'> & {
23
+ nameField: NameField;
24
+ };
25
+ export {};
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2020, salesforce.com, inc.
4
+ * All rights reserved.
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
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/shared/types.ts"],"names":[],"mappings":";AAAA;;;;;GAKG"}
@@ -0,0 +1,11 @@
1
+ # error.labelLength
2
+
3
+ Invalid label: %s. Label must be at least 2 characters.
4
+
5
+ # error.objectDirectory
6
+
7
+ Invalid object path: %s. Choose a folder inside a /objects/ folder in your project.
8
+
9
+ # error.tabsDirectory
10
+
11
+ Invalid tabs path: %s. Choose a folder ending with /tabs in your project.
@@ -0,0 +1,21 @@
1
+ # summary
2
+
3
+ Generate metadata source files for a new platform event.
4
+
5
+ # description
6
+
7
+ This command is interactive and must be run in a Salesforce DX project directory. You're required to specify the event's label with the "--label" flag. The command uses this label to provide intelligent suggestions for other event properties, such as its API name.
8
+
9
+ # flags.label.summary
10
+
11
+ The platform event's label.
12
+
13
+ # examples
14
+
15
+ - Create a platform event with the specified label:
16
+
17
+ <%= config.bin %> <%= command.id %> --label "My Platform Event"
18
+
19
+ # prompts.publishBehavior
20
+
21
+ Do you want platform events to publish after a transaction completes, or immediately?
@@ -0,0 +1,81 @@
1
+ # summary
2
+
3
+ Generate metadata source files for a new custom field on a specified object.
4
+
5
+ # description
6
+
7
+ This command is interactive and must be run in a Salesforce DX project directory. You're required to specify the field's label with the "--label" flag. The command uses this label to provide intelligent suggestions for other field properties, such as its API name.
8
+
9
+ You can generate a custom field on either a standard object, such as Account, or a custom object. In both cases, the source files for the object must already exist in your local project before you run this command. If you create a relationship field, the source files for the parent object must also exist in your local directory. Use the command "sf metadata retrieve -m CustomObject:<object>" to retrieve source files for both standard and custom objects from your org. To create a custom object, run the "sf generate metadata sobject" command or use the Object Manager UI in your Salesforce org.
10
+
11
+ # flags.label.summary
12
+
13
+ The field's label.
14
+
15
+ # flags.object.summary
16
+
17
+ The directory that contains the object's source files.
18
+
19
+ # flags.object.description
20
+
21
+ The object source files in your local project are grouped in a directoy with the same name as the object. Custom object names always end in "__c". An example of the object directory for the Account standard object is "force-app/main/default/objects/Account" An example custom object directory is "force-app/main/default/objects/MyObject__c"
22
+
23
+ If you don't specify this flag, the command prompts you to choose from your local objects.
24
+
25
+ # examples
26
+
27
+ - Create a field with the specified label; the command prompts you for the object:
28
+
29
+ <%= config.bin %> <%= command.id %> --label "My Field"
30
+
31
+ - Specify the local path to the object's folder:
32
+
33
+ <%= config.bin %> <%= command.id %> --label "My Field" --object force-app/main/default/objects/MyObject__c
34
+
35
+ # prompts.type
36
+
37
+ Field type:
38
+
39
+ # prompts.startingNumber
40
+
41
+ Starting number:
42
+
43
+ # prompts.defaultValue
44
+
45
+ Default checkbox value:
46
+
47
+ # prompts.scale
48
+
49
+ Number of decimal places:
50
+
51
+ # prompts.precision
52
+
53
+ Total number of digits, including the decimal places:
54
+
55
+ # prompts.inlineHelpText
56
+
57
+ Help text (the text displayed when users hover over the Info icon next to this field):
58
+
59
+ # prompts.required
60
+
61
+ Does this field always require a value in order to save a record? (Tip: consider using layouts instead to require a value)
62
+
63
+ # prompts.externalId
64
+
65
+ Should this field be set as the unique record identifier from an external system?
66
+
67
+ # prompts.securityClassification
68
+
69
+ Security classification (how sensitive is this field's content):
70
+
71
+ # error.bigObjects
72
+
73
+ This command doesn't support big objects.
74
+
75
+ # error.cmdt
76
+
77
+ This command doesn't support custom metadata types.
78
+
79
+ # success
80
+
81
+ Created %s.
@@ -0,0 +1,58 @@
1
+ # summary
2
+
3
+ Generate metadata source files for a new custom object.
4
+
5
+ # description
6
+
7
+ This command is interactive and must be run in a Salesforce DX project directory. You're required to specify the object's label with the "--label" flag. The command uses this label to provide intelligent suggestions for other object properties, such as its API name and plural label.
8
+
9
+ All Salesforce objects are required to have a Name field, so this command also prompts you for the label and type of the Name field. Run the "sf metadata generate field" command to create additional fields for the object.
10
+
11
+ To reduce the number of prompts, use the "--use-default-features" flag to automatically enable some features, such as reporting and search on the object.
12
+
13
+ # flags.label.summary
14
+
15
+ The custom object's label.
16
+
17
+ # flags.use-default-features.summary
18
+
19
+ Enable all optional features without prompting.
20
+
21
+ # flags.use-default-features.description
22
+
23
+ Enables these features:
24
+
25
+ * Search: Allows users to find the custom object's records when they search, including SOSL.
26
+ * Feeds: Enables feed tracking.
27
+ * Reports: Allows reporting of the data in the custom object records.
28
+ * History: Enables object history tracking.
29
+ * Activities: Allows users to associate tasks and scheduled calendar events related to the custom object records.
30
+ * Bulk API: With Sharing and Streaming API, classifies the custom object as an Enterprise Application object.
31
+ * Sharing: With Bulk API and Streaming API, classifies the custom object as an Enterprise Application object.
32
+ * Streaming API: With Bulk API and Sharing, classifies the custom object as an Enterprise Application object.
33
+
34
+ # examples
35
+
36
+ - Create a custom object with the specified label and be prompted for additional information:
37
+
38
+ <%= config.bin %> <%= command.id %> --label "My Object"
39
+
40
+ - Create a custom object and enable optional features without prompting:
41
+
42
+ <%= config.bin %> <%= command.id %> --label "My Object" --use-default-features
43
+
44
+ # success
45
+
46
+ Created %s.
47
+
48
+ # success.advice
49
+
50
+ The first time you deploy your new custom object to a source-tracking org, the org creates additional properties and sets new defaults on it. For this reason, we recommend that you immediately retrieve the custom object so your local source files are updated with this new information.
51
+
52
+ # success.field
53
+
54
+ Run this command to add a field to your object: sf generate metadata field --object %s --label "Your Field"
55
+
56
+ # prompts.sharingModel
57
+
58
+ Org-wide sharing model (default access level for the object's records):
@@ -0,0 +1,39 @@
1
+ # summary
2
+
3
+ Generate the metadata source files for a new custom tab on a custom object.
4
+
5
+ # description
6
+
7
+ Custom tabs let you display custom object data or other web content in Salesforce. Custom tabs appear in Salesforce as an item in the app’s navigation bar and in the App Launcher.
8
+
9
+ This command must be run in a Salesforce DX project directory. You must pass all required information to it with the required flags. The source files for the custom object for which you're generating a tab don't need to exist in your local project.
10
+
11
+ # flags.object.summary
12
+
13
+ API name of the custom object you're generating a tab for.
14
+
15
+ # flags.object.description
16
+
17
+ The API name for a custom object always ends in "__c", such as "MyObject__c".
18
+
19
+ # flags.directory.summary
20
+
21
+ Path to a "tabs" directory that will contain the source files for your new tab.
22
+
23
+ # flags.icon.summary
24
+
25
+ Number from 1 to 100 that specifies the color scheme and icon for the custom tab.
26
+
27
+ # flags.icon.description
28
+
29
+ See https://lightningdesignsystem.com/icons/\#custom for the available icons.
30
+
31
+ # examples
32
+
33
+ - Create a tab on the MyObject__c custom object:
34
+
35
+ <%= config.bin %> <%= command.id %> --object MyObject__c --icon 54 --directory force-app/main/default/tabs
36
+
37
+ # success
38
+
39
+ Generated a tab file at %s.
@@ -0,0 +1,27 @@
1
+ # objectPrompt
2
+
3
+ What is the parent object for this relationship field?
4
+
5
+ # lookupDeleteConstraint
6
+
7
+ What happens to this field when the parent is deleted?
8
+
9
+ # lookupDeleteConstraint.setNull
10
+
11
+ Clear the value of this field.
12
+
13
+ # lookupDeleteConstraint.restrict
14
+
15
+ Don't allow the parent record from being deleted if there are lookup fields that refer to it.
16
+
17
+ # lookupDeleteConstraint.cascade
18
+
19
+ Delete the lookup record and the associated lookup fields.
20
+
21
+ # writeRequiresMasterRead
22
+
23
+ Allow write access if the parent is readable?
24
+
25
+ # reparentableMasterDetail
26
+
27
+ Allow reparenting to a different parent record?
@@ -0,0 +1,51 @@
1
+ # directory
2
+
3
+ Which local directory do you want to store the source files for this new object?
4
+
5
+ # pluralLabel
6
+
7
+ Plural label:
8
+
9
+ # apiName
10
+
11
+ API name (custom objects and fields must end in "__c" and platform events in "__e"):
12
+
13
+ # description
14
+
15
+ Description (great developers write great descriptions):
16
+
17
+ # error.noDescription
18
+
19
+ Please enter a description. Your future self and others will thank you.
20
+
21
+ # nameFieldPrompts.label
22
+
23
+ What do you want to call the required Name field?
24
+
25
+ # nameFieldPrompts.type
26
+
27
+ What's the type of the required Name field?
28
+
29
+ # nameFieldPrompts.autoNumberFormat
30
+
31
+ Auto number format:
32
+
33
+ # object
34
+
35
+ Which object is this new field for?
36
+
37
+ # picklist.first
38
+
39
+ Enter the first picklist value, which will also be the default:
40
+
41
+ # picklist.additional
42
+
43
+ Enter the next picklist value, or press RETURN to stop adding picklist values.
44
+
45
+ # numberValidationMin
46
+
47
+ %s is too low. Minimum value is %s.
48
+
49
+ # numberValidationMax
50
+
51
+ %s is too high. Maximum value is %s.
@@ -0,0 +1 @@
1
+ {"version":"0.0.8","commands":{"generate:metadata:field":{"id":"generate:metadata:field","summary":"Generate metadata source files for a new custom field on a specified object.","description":"This command is interactive and must be run in a Salesforce DX project directory. You're required to specify the field's label with the \"--label\" flag. The command uses this label to provide intelligent suggestions for other field properties, such as its API name.\n\nYou can generate a custom field on either a standard object, such as Account, or a custom object. In both cases, the source files for the object must already exist in your local project before you run this command. If you create a relationship field, the source files for the parent object must also exist in your local directory. Use the command \"sf metadata retrieve -m CustomObject:<object>\" to retrieve source files for both standard and custom objects from your org. To create a custom object, run the \"sf generate metadata sobject\" command or use the Object Manager UI in your Salesforce org.","strict":true,"pluginName":"@salesforce/plugin-sobject","pluginAlias":"@salesforce/plugin-sobject","pluginType":"core","state":"beta","aliases":[],"examples":["Create a field with the specified label; the command prompts you for the object:\n<%= config.bin %> <%= command.id %> --label \"My Field\"","Specify the local path to the object's folder:\n<%= config.bin %> <%= command.id %> --label \"My Field\" --object force-app/main/default/objects/MyObject__c"],"flags":{"label":{"name":"label","type":"option","char":"l","summary":"The field's label.","required":true,"multiple":false},"object":{"name":"object","type":"option","char":"o","summary":"The directory that contains the object's source files.","description":"The object source files in your local project are grouped in a directoy with the same name as the object. Custom object names always end in \"__c\". An example of the object directory for the Account standard object is \"force-app/main/default/objects/Account\" An example custom object directory is \"force-app/main/default/objects/MyObject__c\"\n\nIf you don't specify this flag, the command prompts you to choose from your local objects.","multiple":false}},"args":[],"requiresProject":true,"_enableJsonFlag":false},"generate:metadata:platformevent":{"id":"generate:metadata:platformevent","summary":"Generate metadata source files for a new platform event.","description":"This command is interactive and must be run in a Salesforce DX project directory. You're required to specify the event's label with the \"--label\" flag. The command uses this label to provide intelligent suggestions for other event properties, such as its API name.","strict":true,"pluginName":"@salesforce/plugin-sobject","pluginAlias":"@salesforce/plugin-sobject","pluginType":"core","state":"beta","aliases":[],"examples":["Create a platform event with the specified label:\n<%= config.bin %> <%= command.id %> --label \"My Platform Event\""],"flags":{"label":{"name":"label","type":"option","char":"l","summary":"The platform event's label.","required":true,"multiple":false}},"args":[],"requiresProject":true,"_enableJsonFlag":false},"generate:metadata:sobject":{"id":"generate:metadata:sobject","summary":"Generate metadata source files for a new custom object.","description":"This command is interactive and must be run in a Salesforce DX project directory. You're required to specify the object's label with the \"--label\" flag. The command uses this label to provide intelligent suggestions for other object properties, such as its API name and plural label.\n\nAll Salesforce objects are required to have a Name field, so this command also prompts you for the label and type of the Name field. Run the \"sf metadata generate field\" command to create additional fields for the object.\n\nTo reduce the number of prompts, use the \"--use-default-features\" flag to automatically enable some features, such as reporting and search on the object.","strict":true,"pluginName":"@salesforce/plugin-sobject","pluginAlias":"@salesforce/plugin-sobject","pluginType":"core","state":"beta","aliases":[],"examples":["Create a custom object with the specified label and be prompted for additional information:\n<%= config.bin %> <%= command.id %> --label \"My Object\"","Create a custom object and enable optional features without prompting:\n<%= config.bin %> <%= command.id %> --label \"My Object\" --use-default-features"],"flags":{"label":{"name":"label","type":"option","char":"l","summary":"The custom object's label.","required":true,"multiple":false},"use-default-features":{"name":"use-default-features","type":"boolean","char":"f","summary":"Enable all optional features without prompting.","description":"Enables these features:\n\n* Search: Allows users to find the custom object's records when they search, including SOSL.\n* Feeds: Enables feed tracking.\n* Reports: Allows reporting of the data in the custom object records.\n* History: Enables object history tracking.\n* Activities: Allows users to associate tasks and scheduled calendar events related to the custom object records.\n* Bulk API: With Sharing and Streaming API, classifies the custom object as an Enterprise Application object.\n* Sharing: With Bulk API and Streaming API, classifies the custom object as an Enterprise Application object.\n* Streaming API: With Bulk API and Sharing, classifies the custom object as an Enterprise Application object.","allowNo":false}},"args":[],"requiresProject":true,"_enableJsonFlag":false},"generate:metadata:tab":{"id":"generate:metadata:tab","summary":"Generate the metadata source files for a new custom tab on a custom object.","description":"Custom tabs let you display custom object data or other web content in Salesforce. Custom tabs appear in Salesforce as an item in the app’s navigation bar and in the App Launcher.\n\nThis command must be run in a Salesforce DX project directory. You must pass all required information to it with the required flags. The source files for the custom object for which you're generating a tab don't need to exist in your local project.","strict":true,"pluginName":"@salesforce/plugin-sobject","pluginAlias":"@salesforce/plugin-sobject","pluginType":"core","state":"beta","aliases":[],"examples":["Create a tab on the MyObject__c custom object:\n<%= config.bin %> <%= command.id %> --object MyObject__c --icon 54 --directory force-app/main/default/tabs"],"flags":{"json":{"name":"json","type":"boolean","description":"Format output as json.","helpGroup":"GLOBAL","allowNo":false},"object":{"name":"object","type":"option","char":"o","summary":"API name of the custom object you're generating a tab for.","description":"The API name for a custom object always ends in \"__c\", such as \"MyObject__c\".","required":true,"multiple":false},"directory":{"name":"directory","type":"option","char":"d","summary":"Path to a \"tabs\" directory that will contain the source files for your new tab.","required":true,"multiple":false},"icon":{"name":"icon","type":"option","char":"i","summary":"Number from 1 to 100 that specifies the color scheme and icon for the custom tab.","description":"See https://lightningdesignsystem.com/icons/\\#custom for the available icons.","required":true,"multiple":false,"default":1}},"args":[],"requiresProject":true}}}