@salesforce/plugin-sobject 1.0.9 → 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/README.md +12 -12
- package/lib/commands/schema/generate/field.d.ts +3 -1
- package/lib/commands/schema/generate/field.js +100 -126
- package/lib/commands/schema/generate/field.js.map +1 -1
- package/lib/commands/schema/generate/platformevent.js +17 -16
- package/lib/commands/schema/generate/platformevent.js.map +1 -1
- package/lib/commands/schema/generate/sobject.js +34 -31
- package/lib/commands/schema/generate/sobject.js.map +1 -1
- package/lib/shared/flags.js.map +1 -1
- package/lib/shared/prompts/apiName.d.ts +5 -0
- package/lib/shared/prompts/apiName.js +26 -0
- package/lib/shared/prompts/apiName.js.map +1 -0
- package/lib/shared/prompts/description.d.ts +3 -0
- package/lib/shared/prompts/description.js +15 -0
- package/lib/shared/prompts/description.js.map +1 -0
- package/lib/shared/prompts/directory.d.ts +3 -0
- package/lib/shared/prompts/directory.js +16 -0
- package/lib/shared/prompts/directory.js.map +1 -0
- package/lib/shared/prompts/fields/number.d.ts +4 -0
- package/lib/shared/prompts/fields/number.js +26 -0
- package/lib/shared/prompts/fields/number.js.map +1 -0
- package/lib/shared/prompts/fields/text.d.ts +2 -0
- package/lib/shared/prompts/fields/text.js +31 -0
- package/lib/shared/prompts/fields/text.js.map +1 -0
- package/lib/shared/prompts/functions.d.ts +8 -0
- package/lib/shared/prompts/functions.js +24 -0
- package/lib/shared/prompts/functions.js.map +1 -0
- package/lib/shared/prompts/nameField.d.ts +5 -0
- package/lib/shared/prompts/nameField.js +31 -0
- package/lib/shared/prompts/nameField.js.map +1 -0
- package/lib/shared/prompts/object.d.ts +8 -0
- package/lib/shared/prompts/object.js +23 -0
- package/lib/shared/prompts/object.js.map +1 -0
- package/lib/shared/prompts/picklist.d.ts +2 -0
- package/lib/shared/prompts/picklist.js +31 -0
- package/lib/shared/prompts/picklist.js.map +1 -0
- package/lib/shared/prompts/plural.d.ts +3 -0
- package/lib/shared/prompts/plural.js +15 -0
- package/lib/shared/prompts/plural.js.map +1 -0
- package/lib/shared/prompts/relationshipField.js +43 -55
- package/lib/shared/prompts/relationshipField.js.map +1 -1
- package/lib/shared/types.d.ts +1 -8
- package/messages/generate.event.md +4 -0
- package/messages/generate.object.md +9 -9
- package/messages/prompts.shared.md +3 -3
- package/oclif.lock +159 -48
- package/oclif.manifest.json +2 -6
- package/package.json +9 -7
- package/schemas/schema-generate-field.json +15 -0
- package/schemas/schema-generate-sobject.json +17 -14
- package/lib/shared/prompts/prompts.d.ts +0 -28
- package/lib/shared/prompts/prompts.js +0 -123
- package/lib/shared/prompts/prompts.js.map +0 -1
package/README.md
CHANGED
|
@@ -161,7 +161,7 @@ FLAG DESCRIPTIONS
|
|
|
161
161
|
If you don't specify this flag, the command prompts you to choose from your local objects.
|
|
162
162
|
```
|
|
163
163
|
|
|
164
|
-
_See code: [src/commands/schema/generate/field.ts](https://github.com/salesforcecli/plugin-sobject/blob/1.0
|
|
164
|
+
_See code: [src/commands/schema/generate/field.ts](https://github.com/salesforcecli/plugin-sobject/blob/1.1.0/src/commands/schema/generate/field.ts)_
|
|
165
165
|
|
|
166
166
|
## `sf schema generate platformevent`
|
|
167
167
|
|
|
@@ -190,7 +190,7 @@ EXAMPLES
|
|
|
190
190
|
$ sf schema generate platformevent --label "My Platform Event"
|
|
191
191
|
```
|
|
192
192
|
|
|
193
|
-
_See code: [src/commands/schema/generate/platformevent.ts](https://github.com/salesforcecli/plugin-sobject/blob/1.0
|
|
193
|
+
_See code: [src/commands/schema/generate/platformevent.ts](https://github.com/salesforcecli/plugin-sobject/blob/1.1.0/src/commands/schema/generate/platformevent.ts)_
|
|
194
194
|
|
|
195
195
|
## `sf schema generate sobject`
|
|
196
196
|
|
|
@@ -234,17 +234,17 @@ FLAG DESCRIPTIONS
|
|
|
234
234
|
|
|
235
235
|
Enables these features:
|
|
236
236
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
237
|
+
- Search: Allows users to find the custom object's records when they search, including SOSL.
|
|
238
|
+
- Feeds: Enables feed tracking.
|
|
239
|
+
- Reports: Allows reporting of the data in the custom object records.
|
|
240
|
+
- History: Enables object history tracking.
|
|
241
|
+
- Activities: Allows users to associate tasks and scheduled calendar events related to the custom object records.
|
|
242
|
+
- Bulk API: With Sharing and Streaming API, classifies the custom object as an Enterprise Application object.
|
|
243
|
+
- Sharing: With Bulk API and Streaming API, classifies the custom object as an Enterprise Application object.
|
|
244
|
+
- Streaming API: With Bulk API and Sharing, classifies the custom object as an Enterprise Application object.
|
|
245
245
|
```
|
|
246
246
|
|
|
247
|
-
_See code: [src/commands/schema/generate/sobject.ts](https://github.com/salesforcecli/plugin-sobject/blob/1.0
|
|
247
|
+
_See code: [src/commands/schema/generate/sobject.ts](https://github.com/salesforcecli/plugin-sobject/blob/1.1.0/src/commands/schema/generate/sobject.ts)_
|
|
248
248
|
|
|
249
249
|
## `sf schema generate tab`
|
|
250
250
|
|
|
@@ -291,6 +291,6 @@ FLAG DESCRIPTIONS
|
|
|
291
291
|
The API name for a custom object always ends in `__c`, such as `MyObject__c`.
|
|
292
292
|
```
|
|
293
293
|
|
|
294
|
-
_See code: [src/commands/schema/generate/tab.ts](https://github.com/salesforcecli/plugin-sobject/blob/1.0
|
|
294
|
+
_See code: [src/commands/schema/generate/tab.ts](https://github.com/salesforcecli/plugin-sobject/blob/1.1.0/src/commands/schema/generate/tab.ts)_
|
|
295
295
|
|
|
296
296
|
<!-- commandsstop -->
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { SfCommand } from '@salesforce/sf-plugins-core';
|
|
2
|
+
import { Messages } from '@salesforce/core';
|
|
2
3
|
import type { CustomField } from 'jsforce/api/metadata';
|
|
4
|
+
export declare const messages: Messages<string>;
|
|
3
5
|
declare const supportedFieldTypesCustomObject: readonly ["AutoNumber", "Checkbox", "Currency", "DateTime", "Date", "Email", "Html", "Location", "LongTextArea", "Lookup", "MasterDetail", "Number", "Phone", "Picklist", "Text", "Time", "Url"];
|
|
4
|
-
type SaveableCustomField = Pick<CustomField, 'label' | 'description' | 'trackHistory' | 'inlineHelpText' | 'required' | 'fullName' | 'type' | 'scale' | 'precision' | 'visibleLines' | 'length'> & {
|
|
6
|
+
type SaveableCustomField = Pick<CustomField, 'label' | 'description' | 'trackHistory' | 'inlineHelpText' | 'required' | 'fullName' | 'type' | 'scale' | 'precision' | 'visibleLines' | 'length' | 'unique' | 'externalId' | 'startingNumber' | 'defaultValue' | 'securityClassification'> & {
|
|
5
7
|
displayLocationInDecimal?: boolean;
|
|
6
8
|
type: (typeof supportedFieldTypesCustomObject)[number];
|
|
7
9
|
};
|
|
@@ -6,16 +6,26 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import fs from 'node:fs';
|
|
8
8
|
import path from 'node:path';
|
|
9
|
+
import input from '@inquirer/input';
|
|
10
|
+
import select from '@inquirer/select';
|
|
11
|
+
import confirm from '@inquirer/confirm';
|
|
9
12
|
import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
|
|
10
13
|
import { Messages } from '@salesforce/core';
|
|
11
14
|
import { convertJsonToXml } from '../../../shared/convert.js';
|
|
12
|
-
import {
|
|
15
|
+
import { picklistPrompts } from '../../../shared/prompts/picklist.js';
|
|
16
|
+
import { integerValidation } from '../../../shared/prompts/functions.js';
|
|
17
|
+
import { apiNamePrompt } from '../../../shared/prompts/apiName.js';
|
|
18
|
+
import { descriptionPrompt } from '../../../shared/prompts/description.js';
|
|
19
|
+
import { objectPrompt } from '../../../shared/prompts/object.js';
|
|
13
20
|
import { relationshipFieldPrompts } from '../../../shared/prompts/relationshipField.js';
|
|
14
21
|
import { isObjectsFolder, labelValidation } from '../../../shared/flags.js';
|
|
22
|
+
import { toSelectOption } from '../../../shared/prompts/functions.js';
|
|
23
|
+
import { lengthPrompt } from '../../../shared/prompts/fields/text.js';
|
|
24
|
+
import { visibleLinePrompt } from '../../../shared/prompts/fields/text.js';
|
|
25
|
+
import { precisionPrompt } from '../../../shared/prompts/fields/number.js';
|
|
26
|
+
import { scalePrompt } from '../../../shared/prompts/fields/number.js';
|
|
15
27
|
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
16
|
-
const messages = Messages.loadMessages('@salesforce/plugin-sobject', 'generate.field');
|
|
17
|
-
const MAX_LONG_TEXT_LENGTH = 131072;
|
|
18
|
-
const MAX_TEXT_LENGTH = 255;
|
|
28
|
+
export const messages = Messages.loadMessages('@salesforce/plugin-sobject', 'generate.field');
|
|
19
29
|
const supportedFieldTypesCustomObject = [
|
|
20
30
|
'AutoNumber',
|
|
21
31
|
'Checkbox',
|
|
@@ -49,7 +59,7 @@ export default class FieldGenerate extends SfCommand {
|
|
|
49
59
|
char: 'l',
|
|
50
60
|
summary: messages.getMessage('flags.label.summary'),
|
|
51
61
|
required: true,
|
|
52
|
-
parse:
|
|
62
|
+
parse: labelValidation,
|
|
53
63
|
}),
|
|
54
64
|
// this a dir and not an API name to support 1 object being in multiple package directories
|
|
55
65
|
object: Flags.directory({
|
|
@@ -57,146 +67,67 @@ export default class FieldGenerate extends SfCommand {
|
|
|
57
67
|
exists: true,
|
|
58
68
|
summary: messages.getMessage('flags.object.summary'),
|
|
59
69
|
description: messages.getMessage('flags.object.description'),
|
|
60
|
-
parse:
|
|
70
|
+
parse: isObjectsFolder,
|
|
61
71
|
}),
|
|
62
72
|
};
|
|
63
73
|
async run() {
|
|
64
74
|
const { flags } = await this.parse(FieldGenerate);
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
type: 'list',
|
|
86
|
-
message: messages.getMessage('prompts.defaultValue'),
|
|
87
|
-
choices: [
|
|
88
|
-
{ value: false, name: 'false' },
|
|
89
|
-
{ value: true, name: 'true' },
|
|
90
|
-
],
|
|
91
|
-
name: 'defaultValue',
|
|
92
|
-
when: (answers) => answers.type === 'Checkbox',
|
|
93
|
-
default: false,
|
|
94
|
-
},
|
|
95
|
-
// text types
|
|
96
|
-
{
|
|
97
|
-
type: 'number',
|
|
98
|
-
message: `Length (max ${MAX_LONG_TEXT_LENGTH})`,
|
|
99
|
-
validate: (n) => integerValidation(n, 1, MAX_LONG_TEXT_LENGTH),
|
|
100
|
-
name: 'length',
|
|
101
|
-
when: (answers) => ['Html', 'LongTextArea'].includes(answers.type),
|
|
102
|
-
default: MAX_LONG_TEXT_LENGTH,
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
type: 'number',
|
|
106
|
-
message: `Length (max ${MAX_TEXT_LENGTH})`,
|
|
107
|
-
validate: (n) => integerValidation(n, 1, MAX_TEXT_LENGTH),
|
|
108
|
-
name: 'length',
|
|
109
|
-
when: (answers) => answers.type === 'Text',
|
|
110
|
-
default: MAX_TEXT_LENGTH,
|
|
111
|
-
},
|
|
112
|
-
{
|
|
113
|
-
type: 'number',
|
|
114
|
-
message: 'Visible Lines',
|
|
115
|
-
validate: (n) => integerValidation(n, 1, 1000),
|
|
116
|
-
name: 'visibleLines',
|
|
117
|
-
when: (answers) => ['Html', 'LongTextArea'].includes(answers.type),
|
|
118
|
-
default: 5,
|
|
119
|
-
},
|
|
120
|
-
// number types
|
|
121
|
-
{
|
|
122
|
-
type: 'number',
|
|
123
|
-
message: messages.getMessage('prompts.scale'),
|
|
124
|
-
validate: (n) => integerValidation(n, 0, 18),
|
|
125
|
-
name: 'scale',
|
|
126
|
-
when: (answers) => ['Number', 'Currency', 'Location'].includes(answers.type),
|
|
127
|
-
default: 0,
|
|
128
|
-
},
|
|
129
|
-
{
|
|
130
|
-
type: 'number',
|
|
131
|
-
message: messages.getMessage('prompts.precision'),
|
|
132
|
-
validate: (n, answers) => integerValidation(n, 1, 18 - (answers.scale ?? 0)),
|
|
133
|
-
name: 'precision',
|
|
134
|
-
when: (answers) => ['Number', 'Currency'].includes(answers.type),
|
|
135
|
-
default: (answers) => 18 - (answers.scale ?? 0),
|
|
136
|
-
},
|
|
137
|
-
// non-fieldtype-specific questions
|
|
138
|
-
descriptionPrompt,
|
|
139
|
-
{
|
|
140
|
-
type: 'input',
|
|
141
|
-
message: messages.getMessage('prompts.inlineHelpText'),
|
|
142
|
-
name: 'inlineHelpText',
|
|
143
|
-
when: (answers) => !answers.object.includes('__e'),
|
|
144
|
-
},
|
|
145
|
-
{
|
|
146
|
-
type: 'confirm',
|
|
147
|
-
message: messages.getMessage('prompts.required'),
|
|
148
|
-
name: 'required',
|
|
149
|
-
when: (answers) => !['Checkbox', 'MasterDetail', 'Lookup', 'LongTextArea'].includes(answers.type),
|
|
150
|
-
default: false,
|
|
151
|
-
},
|
|
152
|
-
{
|
|
153
|
-
type: 'confirm',
|
|
154
|
-
message: 'Unique',
|
|
155
|
-
name: 'unique',
|
|
156
|
-
when: (answers) => ['Number', 'Text'].includes(answers.type),
|
|
157
|
-
default: false,
|
|
158
|
-
},
|
|
159
|
-
{
|
|
160
|
-
type: 'confirm',
|
|
161
|
-
message: messages.getMessage('prompts.externalId'),
|
|
162
|
-
name: 'externalId',
|
|
163
|
-
when: (answers) => ['Number', 'Text'].includes(answers.type) && answers.object?.endsWith('__e'),
|
|
164
|
-
default: false,
|
|
165
|
-
},
|
|
166
|
-
{
|
|
167
|
-
type: 'list',
|
|
168
|
-
message: messages.getMessage('prompts.securityClassification'),
|
|
169
|
-
name: 'securityClassification',
|
|
170
|
-
choices: ['Public', 'Internal', 'Confidential', 'Restricted', 'Mission Critical'],
|
|
171
|
-
default: 'Internal',
|
|
172
|
-
},
|
|
173
|
-
],
|
|
174
|
-
// pre-populate the object if they gave us one
|
|
175
|
-
flags.object ? { object: flags.object } : {});
|
|
176
|
-
const { object, ...customField } = responses;
|
|
75
|
+
const object = flags.object ?? (await objectPrompt(this.project.getPackageDirectories()));
|
|
76
|
+
const fullName = await apiNamePrompt(flags.label, 'CustomField');
|
|
77
|
+
const type = (await select({
|
|
78
|
+
message: messages.getMessage('prompts.type'),
|
|
79
|
+
choices: getSupportedFieldTypes(object).map(toSelectOption),
|
|
80
|
+
// select accepts a type param, but either TS or inquirer isn't happy with the typing of it
|
|
81
|
+
}));
|
|
82
|
+
const startingNumber = await startingNumberPrompt(type);
|
|
83
|
+
const defaultValue = await defaultValuePrompt(type);
|
|
84
|
+
const length = await lengthPrompt(type);
|
|
85
|
+
const visibleLines = await visibleLinePrompt(type);
|
|
86
|
+
// number types
|
|
87
|
+
const scale = await scalePrompt(type);
|
|
88
|
+
const precision = await precisionPrompt(type, scale);
|
|
89
|
+
// non-fieldtype-specific questions
|
|
90
|
+
const description = await descriptionPrompt();
|
|
91
|
+
const inlineHelpText = await inlineHelpPrompt(object);
|
|
92
|
+
const required = await requiredPrompt(type);
|
|
93
|
+
const unique = await uniquePrompt(type);
|
|
94
|
+
const externalId = await externalIdPrompt(type, object);
|
|
177
95
|
const result = {
|
|
178
96
|
field: {
|
|
179
|
-
|
|
97
|
+
fullName,
|
|
98
|
+
type,
|
|
99
|
+
...(precision !== undefined ? { precision } : {}),
|
|
100
|
+
...(scale !== undefined ? { scale } : {}),
|
|
101
|
+
...(visibleLines !== undefined ? { visibleLines } : {}),
|
|
102
|
+
...(length !== undefined ? { length } : {}),
|
|
103
|
+
...(inlineHelpText !== undefined ? { inlineHelpText } : {}),
|
|
104
|
+
...(required !== undefined ? { required } : {}),
|
|
105
|
+
...(unique !== undefined ? { unique } : {}),
|
|
106
|
+
...(externalId !== undefined ? { externalId } : {}),
|
|
107
|
+
...(startingNumber !== undefined ? { startingNumber } : {}),
|
|
108
|
+
...(defaultValue !== undefined ? { defaultValue } : {}),
|
|
109
|
+
description,
|
|
180
110
|
label: flags.label,
|
|
181
111
|
// always use decimal version of location unless someone asks us not to in a feature request
|
|
182
|
-
...(
|
|
112
|
+
...(type === 'Location' ? { displayLocationInDecimal: true } : {}),
|
|
183
113
|
// building picklists is an independent inquirer series of questions
|
|
184
|
-
...(
|
|
114
|
+
...(type === 'Picklist' ? { valueSet: await picklistPrompts() } : {}),
|
|
185
115
|
// relationship fields have their own series of questions
|
|
186
|
-
...(
|
|
116
|
+
...(type === 'MasterDetail' || type === 'Lookup'
|
|
187
117
|
? await relationshipFieldPrompts({
|
|
188
|
-
type
|
|
118
|
+
type,
|
|
189
119
|
packageDirs: this.project.getPackageDirectories(),
|
|
190
|
-
childObjectFolderPath:
|
|
120
|
+
childObjectFolderPath: object,
|
|
191
121
|
})
|
|
192
122
|
: {}),
|
|
123
|
+
securityClassification: await securityPrompt(),
|
|
193
124
|
},
|
|
194
|
-
path: path.join(object, 'fields', `${
|
|
125
|
+
path: path.join(object, 'fields', `${fullName}.field-meta.xml`),
|
|
195
126
|
};
|
|
196
127
|
this.styledJSON(result);
|
|
197
128
|
await fs.promises.mkdir(path.join(object, 'fields'), { recursive: true });
|
|
198
129
|
await fs.promises.writeFile(result.path, convertJsonToXml({ json: result.field, type: 'CustomField' }));
|
|
199
|
-
this.logSuccess(messages.getMessage('success', [path.join(object, 'fields', `${
|
|
130
|
+
this.logSuccess(messages.getMessage('success', [path.join(object, 'fields', `${fullName}.field-meta.xml`)]));
|
|
200
131
|
return result;
|
|
201
132
|
}
|
|
202
133
|
}
|
|
@@ -216,4 +147,47 @@ const getSupportedFieldTypes = (objFolder) => {
|
|
|
216
147
|
}
|
|
217
148
|
return supportedFieldTypesCustomObject;
|
|
218
149
|
};
|
|
150
|
+
// checkbox type requires a default value
|
|
151
|
+
const defaultValuePrompt = async (type) => type === 'Checkbox'
|
|
152
|
+
? select({
|
|
153
|
+
message: messages.getMessage('prompts.defaultValue'),
|
|
154
|
+
choices: [{ value: 'false' }, { value: 'true' }],
|
|
155
|
+
default: 'false',
|
|
156
|
+
})
|
|
157
|
+
: undefined;
|
|
158
|
+
const startingNumberPrompt = async (type) => type === 'AutoNumber'
|
|
159
|
+
? Number(await input({
|
|
160
|
+
message: messages.getMessage('prompts.startingNumber'),
|
|
161
|
+
default: '0',
|
|
162
|
+
validate: integerValidation({ min: 0, max: Number.MAX_SAFE_INTEGER }),
|
|
163
|
+
}))
|
|
164
|
+
: undefined;
|
|
165
|
+
const securityPrompt = async () => select({
|
|
166
|
+
message: messages.getMessage('prompts.securityClassification'),
|
|
167
|
+
choices: ['Public', 'Internal', 'Confidential', 'Restricted', 'Mission Critical'].map(toSelectOption),
|
|
168
|
+
default: 'Internal',
|
|
169
|
+
});
|
|
170
|
+
const externalIdPrompt = async (type, object) => (type === 'Number' || type === 'Text') && !object.endsWith('__e')
|
|
171
|
+
? confirm({
|
|
172
|
+
message: messages.getMessage('prompts.externalId'),
|
|
173
|
+
default: false,
|
|
174
|
+
})
|
|
175
|
+
: undefined;
|
|
176
|
+
const uniquePrompt = async (type) => type === 'Number' || type === 'Text'
|
|
177
|
+
? confirm({
|
|
178
|
+
message: 'Unique',
|
|
179
|
+
default: false,
|
|
180
|
+
})
|
|
181
|
+
: undefined;
|
|
182
|
+
const requiredPrompt = async (type) => ['Checkbox', 'MasterDetail', 'Lookup', 'LongTextArea'].includes(type)
|
|
183
|
+
? undefined
|
|
184
|
+
: confirm({
|
|
185
|
+
message: messages.getMessage('prompts.required'),
|
|
186
|
+
default: false,
|
|
187
|
+
});
|
|
188
|
+
const inlineHelpPrompt = async (object) => object.includes('__e')
|
|
189
|
+
? undefined
|
|
190
|
+
: input({
|
|
191
|
+
message: messages.getMessage('prompts.inlineHelpText'),
|
|
192
|
+
});
|
|
219
193
|
//# sourceMappingURL=field.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field.js","sourceRoot":"","sources":["../../../../src/commands/schema/generate/field.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"field.js","sourceRoot":"","sources":["../../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A+B,EAAE,CAC7E,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;IACpB,CAAC,CAAC,SAAS;IACX,CAAC,CAAC,KAAK,CAAC;QACJ,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,wBAAwB,CAAC;KACvD,CAAC,CAAC"}
|
|
@@ -4,11 +4,17 @@
|
|
|
4
4
|
* Licensed under the BSD 3-Clause license.
|
|
5
5
|
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
6
6
|
*/
|
|
7
|
+
import { dirname } from 'node:path';
|
|
7
8
|
import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
|
|
8
9
|
import { Messages } from '@salesforce/core';
|
|
9
|
-
import
|
|
10
|
+
import select from '@inquirer/select';
|
|
11
|
+
import { apiNamePrompt } from '../../../shared/prompts/apiName.js';
|
|
12
|
+
import { pluralPrompt } from '../../../shared/prompts/plural.js';
|
|
13
|
+
import { directoryPrompt } from '../../../shared/prompts/directory.js';
|
|
14
|
+
import { descriptionPrompt } from '../../../shared/prompts/description.js';
|
|
10
15
|
import { writeObjectFile } from '../../../shared/fs.js';
|
|
11
16
|
import { labelValidation } from '../../../shared/flags.js';
|
|
17
|
+
import { toSelectOption } from '../../../shared/prompts/functions.js';
|
|
12
18
|
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
13
19
|
const messages = Messages.loadMessages('@salesforce/plugin-sobject', 'generate.event');
|
|
14
20
|
export default class PlatformEventGenerate extends SfCommand {
|
|
@@ -24,32 +30,27 @@ export default class PlatformEventGenerate extends SfCommand {
|
|
|
24
30
|
char: 'l',
|
|
25
31
|
summary: messages.getMessage('flags.label.summary'),
|
|
26
32
|
required: true,
|
|
27
|
-
parse:
|
|
33
|
+
parse: labelValidation,
|
|
28
34
|
}),
|
|
29
35
|
};
|
|
30
36
|
async run() {
|
|
31
37
|
const { flags } = await this.parse(PlatformEventGenerate);
|
|
32
|
-
const
|
|
33
|
-
await directoryPrompt(this.project.getPackageDirectories()),
|
|
34
|
-
pluralPrompt(flags.label),
|
|
35
|
-
apiNamePrompt(flags.label, 'PlatformEvent'),
|
|
36
|
-
descriptionPrompt,
|
|
37
|
-
{
|
|
38
|
-
type: 'list',
|
|
39
|
-
message: messages.getMessage('prompts.publishBehavior'),
|
|
40
|
-
name: 'publishBehavior',
|
|
41
|
-
choices: ['PublishImmediately', 'PublishAfterCommit'],
|
|
42
|
-
},
|
|
43
|
-
]);
|
|
44
|
-
const { directory, ...platformEvent } = responses;
|
|
38
|
+
const directory = await directoryPrompt(this.project.getPackageDirectories());
|
|
45
39
|
const objectToWrite = {
|
|
46
|
-
|
|
40
|
+
fullName: await apiNamePrompt(flags.label, 'PlatformEvent'),
|
|
41
|
+
pluralLabel: await pluralPrompt(flags.label),
|
|
42
|
+
description: await descriptionPrompt(),
|
|
43
|
+
publishBehavior: await select({
|
|
44
|
+
message: messages.getMessage('prompts.publishBehavior'),
|
|
45
|
+
choices: ['PublishImmediately', 'PublishAfterCommit'].map(toSelectOption),
|
|
46
|
+
}),
|
|
47
47
|
deploymentStatus: 'Deployed',
|
|
48
48
|
eventType: 'HighVolume',
|
|
49
49
|
label: flags.label,
|
|
50
50
|
};
|
|
51
51
|
this.styledJSON(objectToWrite);
|
|
52
52
|
const writePath = await writeObjectFile(directory, objectToWrite);
|
|
53
|
+
this.info(messages.getMessage('success.field', [dirname(writePath)]));
|
|
53
54
|
return { object: objectToWrite, path: writePath };
|
|
54
55
|
}
|
|
55
56
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platformevent.js","sourceRoot":"","sources":["../../../../src/commands/schema/generate/platformevent.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"platformevent.js","sourceRoot":"","sources":["../../../../src/commands/schema/generate/platformevent.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,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-3-Clause
|
|
6
6
|
*/
|
|
7
7
|
import { dirname } from 'node:path';
|
|
8
|
+
import select from '@inquirer/select';
|
|
9
|
+
import confirm from '@inquirer/confirm';
|
|
8
10
|
import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
|
|
9
11
|
import { Messages } from '@salesforce/core';
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
+
import { nameFieldPrompts } from '../../../shared/prompts/nameField.js';
|
|
13
|
+
import { apiNamePrompt } from '../../../shared/prompts/apiName.js';
|
|
14
|
+
import { pluralPrompt } from '../../../shared/prompts/plural.js';
|
|
15
|
+
import { directoryPrompt } from '../../../shared/prompts/directory.js';
|
|
16
|
+
import { descriptionPrompt } from '../../../shared/prompts/description.js';
|
|
12
17
|
import { writeObjectFile } from '../../../shared/fs.js';
|
|
13
18
|
import { labelValidation } from '../../../shared/flags.js';
|
|
14
19
|
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
@@ -46,37 +51,19 @@ export default class ObjectGenerate extends SfCommand {
|
|
|
46
51
|
};
|
|
47
52
|
async run() {
|
|
48
53
|
const { flags } = await this.parse(ObjectGenerate);
|
|
49
|
-
const
|
|
50
|
-
await directoryPrompt(this.project.getPackageDirectories()),
|
|
51
|
-
pluralPrompt(flags.label),
|
|
52
|
-
apiNamePrompt(flags.label, 'CustomObject'),
|
|
53
|
-
descriptionPrompt,
|
|
54
|
-
...namePrompts(flags.label),
|
|
55
|
-
// transform the default features into confirm prompts
|
|
56
|
-
...Object.keys(defaultFeatures).map((name) => ({
|
|
57
|
-
type: 'confirm',
|
|
58
|
-
name,
|
|
59
|
-
message: sentenceCase(name).replace('Api', 'API'),
|
|
60
|
-
})),
|
|
61
|
-
{
|
|
62
|
-
type: 'list',
|
|
63
|
-
choices: ['ReadWrite', 'Read', 'Private'],
|
|
64
|
-
message: messages.getMessage('prompts.sharingModel'),
|
|
65
|
-
name: 'sharingModel',
|
|
66
|
-
},
|
|
67
|
-
], flags['use-default-features'] ? defaultFeatures : {});
|
|
68
|
-
const { nameFieldType, nameFieldLabel, autoNumberFormat, directory, ...customObject } = responses;
|
|
54
|
+
const directory = await directoryPrompt(this.project.getPackageDirectories());
|
|
69
55
|
const resultsObject = {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
56
|
+
pluralLabel: await pluralPrompt(flags.label),
|
|
57
|
+
fullName: await apiNamePrompt(flags.label, 'CustomObject'),
|
|
58
|
+
description: await descriptionPrompt(),
|
|
59
|
+
nameField: await nameFieldPrompts(flags.label),
|
|
60
|
+
...(flags['use-default-features'] ? defaultFeatures : await promptForDefaultFeatures()),
|
|
61
|
+
sharingModel: await select({
|
|
62
|
+
message: messages.getMessage('prompts.sharingModel'),
|
|
63
|
+
choices: [{ value: 'ReadWrite' }, { value: 'Read' }, { value: 'Private' }],
|
|
64
|
+
}),
|
|
79
65
|
label: flags.label,
|
|
66
|
+
deploymentStatus: 'Deployed',
|
|
80
67
|
};
|
|
81
68
|
this.styledJSON(resultsObject);
|
|
82
69
|
const writePath = await writeObjectFile(directory, resultsObject);
|
|
@@ -87,4 +74,20 @@ export default class ObjectGenerate extends SfCommand {
|
|
|
87
74
|
return { object: resultsObject, path: writePath };
|
|
88
75
|
}
|
|
89
76
|
}
|
|
77
|
+
const promptForDefaultFeatures = async () => {
|
|
78
|
+
const enterprise = await confirm({
|
|
79
|
+
message: 'Enable Enterprise Features (Sharing, Bulk API, and Streaming API)',
|
|
80
|
+
default: true,
|
|
81
|
+
});
|
|
82
|
+
return {
|
|
83
|
+
enableBulkApi: enterprise,
|
|
84
|
+
enableSharing: enterprise,
|
|
85
|
+
enableStreamingApi: enterprise,
|
|
86
|
+
enableHistory: await confirm({ message: 'Enable History', default: true }),
|
|
87
|
+
enableActivities: await confirm({ message: 'Enable Activities', default: true }),
|
|
88
|
+
enableSearch: await confirm({ message: 'Enable Search', default: true }),
|
|
89
|
+
enableFeeds: await confirm({ message: 'Enable Feeds', default: true }),
|
|
90
|
+
enableReports: await confirm({ message: 'Enable Reports', default: true }),
|
|
91
|
+
};
|
|
92
|
+
};
|
|
90
93
|
//# sourceMappingURL=sobject.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sobject.js","sourceRoot":"","sources":["../../../../src/commands/schema/generate/sobject.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"sobject.js","sourceRoot":"","sources":["../../../../src/commands/schema/generate/sobject.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,MAAM,MAAM,kBAAkB,CAAC;AACtC,OAAO,OAAO,MAAM,mBAAmB,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AACvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAE3D,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,4BAA4B,EAAE,iBAAiB,CAAC,CAAC;AAmBxF,MAAM,eAAe,GAAoB;IACv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U,CAAC,gBAAgB,CAAC,CAAC,CAAC;QACjD,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;IACpD,CAAC;;AAGH,MAAM,wBAAwB,GAAG,KAAK,IAA8B,EAAE;IACpE,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC;QAC/B,OAAO,EAAE,mEAAmE;QAC5E,OAAO,EAAE,IAAI;KACd,CAAC,CAAC;IACH,OAAO;QACL,aAAa,EAAE,UAAU;QACzB,aAAa,EAAE,UAAU;QACzB,kBAAkB,EAAE,UAAU;QAC9B,aAAa,EAAE,MAAM,OAAO,CAAC,EAAE,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;QAC1E,gBAAgB,EAAE,MAAM,OAAO,CAAC,EAAE,OAAO,EAAE,mBAAmB,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;QAChF,YAAY,EAAE,MAAM,OAAO,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;QACxE,WAAW,EAAE,MAAM,OAAO,CAAC,EAAE,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;QACtE,aAAa,EAAE,MAAM,OAAO,CAAC,EAAE,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;KAC3E,CAAC;AACJ,CAAC,CAAC"}
|
package/lib/shared/flags.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flags.js","sourceRoot":"","sources":["../../src/shared/flags.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"flags.js","sourceRoot":"","sources":["../../src/shared/flags.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,EAAE,QAAQ,EAAE,OAAO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;QAC7B,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,MAAM,IAAI,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,qBAAqB,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACxE,CAAC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Messages } from '@salesforce/core';
|
|
2
|
+
export declare const messages: Messages<string>;
|
|
3
|
+
export declare const apiNamePrompt: (label: string, objectType: ObjectType) => Promise<string>;
|
|
4
|
+
type ObjectType = 'CustomObject' | 'PlatformEvent' | 'CustomField';
|
|
5
|
+
export {};
|