@salesforce/plugin-sobject 1.0.9 → 1.1.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/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 +186 -75
- package/oclif.manifest.json +2 -6
- package/package.json +10 -8
- 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
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { ValueSet } from 'jsforce/api/metadata';
|
|
2
|
-
import { type NamedPackageDir } from '@salesforce/core';
|
|
3
|
-
import { Prompter } from '@salesforce/sf-plugins-core';
|
|
4
|
-
export declare const makeNameApiCompatible: (input: string) => string;
|
|
5
|
-
type ObjectType = 'CustomObject' | 'PlatformEvent' | 'CustomField';
|
|
6
|
-
export declare const directoryPrompt: (packageDirs: NamedPackageDir[]) => Promise<Prompter.Answers>;
|
|
7
|
-
export declare const pluralPrompt: (label: string) => Prompter.Answers;
|
|
8
|
-
export declare const apiNamePrompt: (label: string, objectType: ObjectType) => Prompter.Answers;
|
|
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) => Prompter.Answers[];
|
|
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<Prompter.Answers>;
|
|
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 {};
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2020, salesforce.com, inc.
|
|
3
|
-
* All rights reserved.
|
|
4
|
-
* Licensed under the BSD 3-Clause license.
|
|
5
|
-
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
6
|
-
*/
|
|
7
|
-
import { Messages } from '@salesforce/core';
|
|
8
|
-
import { Prompter } from '@salesforce/sf-plugins-core';
|
|
9
|
-
import { getDirectoriesThatContainObjects, getObjectDirectories } from '../fs.js';
|
|
10
|
-
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
11
|
-
const messages = Messages.loadMessages('@salesforce/plugin-sobject', 'prompts.shared');
|
|
12
|
-
export const makeNameApiCompatible = (input) => input.replace(/ /g, '').replace(/-/g, '_').replace(/_{2,}/g, '_');
|
|
13
|
-
const getSuffix = (objectType) => {
|
|
14
|
-
switch (objectType) {
|
|
15
|
-
case 'CustomObject':
|
|
16
|
-
case 'CustomField':
|
|
17
|
-
return '__c';
|
|
18
|
-
case 'PlatformEvent':
|
|
19
|
-
return '__e';
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
export const directoryPrompt = async (packageDirs) => ({
|
|
23
|
-
type: 'list',
|
|
24
|
-
message: messages.getMessage('directory'),
|
|
25
|
-
name: 'directory',
|
|
26
|
-
choices: await getDirectoriesThatContainObjects(packageDirs.map((pd) => pd.path)),
|
|
27
|
-
});
|
|
28
|
-
export const pluralPrompt = (label) => ({
|
|
29
|
-
type: 'input',
|
|
30
|
-
message: messages.getMessage('pluralLabel'),
|
|
31
|
-
name: 'pluralLabel',
|
|
32
|
-
default: `${label}s`,
|
|
33
|
-
});
|
|
34
|
-
export const apiNamePrompt = (label, objectType) => ({
|
|
35
|
-
type: 'input',
|
|
36
|
-
message: messages.getMessage('apiName'),
|
|
37
|
-
name: 'fullName',
|
|
38
|
-
default: `${makeNameApiCompatible(label)}${getSuffix(objectType)}`,
|
|
39
|
-
});
|
|
40
|
-
export const descriptionPrompt = {
|
|
41
|
-
type: 'input',
|
|
42
|
-
message: messages.getMessage('description'),
|
|
43
|
-
name: 'description',
|
|
44
|
-
validate: (input) => (input.length ? true : messages.getMessage('error.noDescription')),
|
|
45
|
-
};
|
|
46
|
-
/** Ask about the name/type for the Name field, with a followup for AutoNumber format if AutoNumber is chosen */
|
|
47
|
-
export const namePrompts = (label) => [
|
|
48
|
-
{
|
|
49
|
-
type: 'input',
|
|
50
|
-
message: messages.getMessage('nameFieldPrompts.label'),
|
|
51
|
-
name: 'nameFieldLabel',
|
|
52
|
-
default: `${label} Name`,
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
type: 'list',
|
|
56
|
-
message: messages.getMessage('nameFieldPrompts.type'),
|
|
57
|
-
name: 'nameFieldType',
|
|
58
|
-
default: 'Text',
|
|
59
|
-
choices: ['Text', 'AutoNumber'],
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
type: 'input',
|
|
63
|
-
when: (answers) => answers.nameFieldType === 'AutoNumber',
|
|
64
|
-
message: messages.getMessage('nameFieldPrompts.autoNumberFormat'),
|
|
65
|
-
name: 'autoNumberFormat',
|
|
66
|
-
default: `${label}-{0}`,
|
|
67
|
-
},
|
|
68
|
-
];
|
|
69
|
-
/**
|
|
70
|
-
*
|
|
71
|
-
* @param packageDirs
|
|
72
|
-
* @param name The "name" property of the Inquirer answer object. Supports use of the question for multiple scenarios
|
|
73
|
-
*/
|
|
74
|
-
export const objectPrompt = async (packageDirs, name = 'object', message = messages.getMessage('object')) => ({
|
|
75
|
-
type: 'list',
|
|
76
|
-
message,
|
|
77
|
-
name,
|
|
78
|
-
choices: (await getObjectDirectories(packageDirs.map((pd) => pd.path)))
|
|
79
|
-
.sort()
|
|
80
|
-
.map((objDir) => ({ value: objDir, name: objDir.split('/').pop() })),
|
|
81
|
-
});
|
|
82
|
-
export const integerValidation = (value, min, max) => {
|
|
83
|
-
if (value < min)
|
|
84
|
-
return messages.getMessage('numberValidationMin', [value, min]);
|
|
85
|
-
if (value > max)
|
|
86
|
-
return messages.getMessage('numberValidationMax', [value, max]);
|
|
87
|
-
return true;
|
|
88
|
-
};
|
|
89
|
-
/**
|
|
90
|
-
* recursively keep adding picklist values until the user says to stop
|
|
91
|
-
*/
|
|
92
|
-
export const picklistPrompts = async () => {
|
|
93
|
-
const output = [];
|
|
94
|
-
let keepAsking = true;
|
|
95
|
-
const prompter = new Prompter();
|
|
96
|
-
while (keepAsking) {
|
|
97
|
-
// the very definition of needing a loop for an await
|
|
98
|
-
// eslint-disable-next-line no-await-in-loop
|
|
99
|
-
const response = await prompter.prompt({
|
|
100
|
-
type: 'input',
|
|
101
|
-
name: 'picklistValue',
|
|
102
|
-
validate: (input) => (output.find((v) => v.fullName === input) ? `${input} already exists` : true),
|
|
103
|
-
message: output.length === 0 ? messages.getMessage('picklist.first') : messages.getMessage('picklist.additional'),
|
|
104
|
-
});
|
|
105
|
-
if (response.picklistValue === undefined || response.picklistValue === '') {
|
|
106
|
-
keepAsking = false;
|
|
107
|
-
}
|
|
108
|
-
else {
|
|
109
|
-
output.push({
|
|
110
|
-
fullName: response.picklistValue,
|
|
111
|
-
label: response.picklistValue,
|
|
112
|
-
default: output.length === 0,
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
return {
|
|
117
|
-
valueSetDefinition: {
|
|
118
|
-
value: output,
|
|
119
|
-
sorted: true,
|
|
120
|
-
},
|
|
121
|
-
};
|
|
122
|
-
};
|
|
123
|
-
//# sourceMappingURL=prompts.js.map
|
|
@@ -1 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