@salesforce/plugin-sobject 0.2.14 → 0.2.16

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 (34) hide show
  1. package/README.md +4 -4
  2. package/lib/commands/schema/generate/field.d.ts +2 -2
  3. package/lib/commands/schema/generate/field.js +47 -51
  4. package/lib/commands/schema/generate/field.js.map +1 -1
  5. package/lib/commands/schema/generate/platformevent.d.ts +2 -2
  6. package/lib/commands/schema/generate/platformevent.js +30 -33
  7. package/lib/commands/schema/generate/platformevent.js.map +1 -1
  8. package/lib/commands/schema/generate/sobject.d.ts +3 -3
  9. package/lib/commands/schema/generate/sobject.js +39 -43
  10. package/lib/commands/schema/generate/sobject.js.map +1 -1
  11. package/lib/commands/schema/generate/tab.d.ts +3 -3
  12. package/lib/commands/schema/generate/tab.js +41 -45
  13. package/lib/commands/schema/generate/tab.js.map +1 -1
  14. package/lib/index.d.ts +1 -1
  15. package/lib/index.js +1 -2
  16. package/lib/index.js.map +1 -1
  17. package/lib/shared/convert.d.ts +1 -1
  18. package/lib/shared/convert.js +4 -8
  19. package/lib/shared/convert.js.map +1 -1
  20. package/lib/shared/flags.js +13 -18
  21. package/lib/shared/flags.js.map +1 -1
  22. package/lib/shared/fs.d.ts +1 -1
  23. package/lib/shared/fs.js +10 -17
  24. package/lib/shared/fs.js.map +1 -1
  25. package/lib/shared/prompts/prompts.d.ts +6 -6
  26. package/lib/shared/prompts/prompts.js +27 -29
  27. package/lib/shared/prompts/prompts.js.map +1 -1
  28. package/lib/shared/prompts/relationshipField.js +14 -16
  29. package/lib/shared/prompts/relationshipField.js.map +1 -1
  30. package/lib/shared/types.js +1 -2
  31. package/lib/shared/types.js.map +1 -1
  32. package/oclif.lock +7986 -0
  33. package/oclif.manifest.json +188 -78
  34. package/package.json +29 -53
@@ -1,21 +1,49 @@
1
- "use strict";
2
1
  /*
3
2
  * Copyright (c) 2022, salesforce.com, inc.
4
3
  * All rights reserved.
5
4
  * Licensed under the BSD 3-Clause license.
6
5
  * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
7
6
  */
8
- var _a;
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- const fs = require("fs");
11
- const path = require("path");
12
- const sf_plugins_core_1 = require("@salesforce/sf-plugins-core");
13
- const core_1 = require("@salesforce/core");
14
- const flags_1 = require("../../../shared/flags");
15
- const convert_1 = require("../../../shared/convert");
16
- core_1.Messages.importMessagesDirectory(__dirname);
17
- const messages = core_1.Messages.loadMessages('@salesforce/plugin-sobject', 'generate.tab');
18
- class GenerateTab extends sf_plugins_core_1.SfCommand {
7
+ import fs from 'node:fs';
8
+ import path, { dirname } from 'node:path';
9
+ import { fileURLToPath } from 'node:url';
10
+ import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
11
+ import { Messages } from '@salesforce/core';
12
+ import { isTabsFolder } from '../../../shared/flags.js';
13
+ import { convertJsonToXml } from '../../../shared/convert.js';
14
+ Messages.importMessagesDirectory(dirname(fileURLToPath(import.meta.url)));
15
+ const messages = Messages.loadMessages('@salesforce/plugin-sobject', 'generate.tab');
16
+ export default class GenerateTab extends SfCommand {
17
+ static summary = messages.getMessage('summary');
18
+ static description = messages.getMessage('description');
19
+ static examples = messages.getMessages('examples');
20
+ static requiresProject = true;
21
+ static aliases = ['generate:metadata:tab'];
22
+ static deprecateAliases = true;
23
+ static flags = {
24
+ object: Flags.string({
25
+ summary: messages.getMessage('flags.object.summary'),
26
+ description: messages.getMessage('flags.object.description'),
27
+ char: 'o',
28
+ required: true,
29
+ }),
30
+ directory: Flags.directory({
31
+ summary: messages.getMessage('flags.directory.summary'),
32
+ char: 'd',
33
+ required: true,
34
+ exists: true,
35
+ parse: async (input) => isTabsFolder(input),
36
+ }),
37
+ icon: Flags.integer({
38
+ char: 'i',
39
+ required: true,
40
+ min: 1,
41
+ max: 100,
42
+ default: 1,
43
+ summary: messages.getMessage('flags.icon.summary'),
44
+ description: messages.getMessage('flags.icon.description'),
45
+ }),
46
+ };
19
47
  async run() {
20
48
  const { flags } = await this.parse(GenerateTab);
21
49
  const tabPath = path.join(flags.directory, `${flags.object}.tab-meta.xml`);
@@ -23,7 +51,7 @@ class GenerateTab extends sf_plugins_core_1.SfCommand {
23
51
  customObject: true,
24
52
  motif: tabDefs.find((tabDef) => tabDef.includes(`Custom${flags.icon}:`)),
25
53
  };
26
- await fs.promises.writeFile(tabPath, (0, convert_1.convertJsonToXml)({ json: tab, type: 'CustomTab' }));
54
+ await fs.promises.writeFile(tabPath, convertJsonToXml({ json: tab, type: 'CustomTab' }));
27
55
  this.logSuccess(messages.getMessage('success', [tabPath]));
28
56
  return {
29
57
  tab,
@@ -31,38 +59,6 @@ class GenerateTab extends sf_plugins_core_1.SfCommand {
31
59
  };
32
60
  }
33
61
  }
34
- exports.default = GenerateTab;
35
- _a = GenerateTab;
36
- GenerateTab.summary = messages.getMessage('summary');
37
- GenerateTab.description = messages.getMessage('description');
38
- GenerateTab.examples = messages.getMessages('examples');
39
- GenerateTab.requiresProject = true;
40
- GenerateTab.aliases = ['generate:metadata:tab'];
41
- GenerateTab.deprecateAliases = true;
42
- GenerateTab.flags = {
43
- object: sf_plugins_core_1.Flags.string({
44
- summary: messages.getMessage('flags.object.summary'),
45
- description: messages.getMessage('flags.object.description'),
46
- char: 'o',
47
- required: true,
48
- }),
49
- directory: sf_plugins_core_1.Flags.directory({
50
- summary: messages.getMessage('flags.directory.summary'),
51
- char: 'd',
52
- required: true,
53
- exists: true,
54
- parse: async (input) => (0, flags_1.isTabsFolder)(input),
55
- }),
56
- icon: sf_plugins_core_1.Flags.integer({
57
- char: 'i',
58
- required: true,
59
- min: 1,
60
- max: 100,
61
- default: 1,
62
- summary: messages.getMessage('flags.icon.summary'),
63
- description: messages.getMessage('flags.icon.description'),
64
- }),
65
- };
66
62
  const tabDefs = [
67
63
  'Custom20: Airplane',
68
64
  'Custom25: Alarm clock',
@@ -1 +1 @@
1
- {"version":3,"file":"tab.js","source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B;IACpB,qBAAqB;IACrB,kBAAkB;IAClB,kBAAkB;IAClB,gBAAgB;IAChB,yBAAyB;IACzB,iBAAiB;IACjB,gBAAgB;IAChB,gBAAgB;IAChB,uBAAuB;IACvB,qBAAqB;IACrB,uBAAuB;IACvB,cAAc;IACd,qBAAqB;IACrB,uBAAuB;IACvB,kBAAkB;IAClB,iBAAiB;IACjB,0BAA0B;IAC1B,mBAAmB;IACnB,kBAAkB;IAClB,iBAAiB;IACjB,0BAA0B;IAC1B,oBAAoB;IACpB,mBAAmB;IACnB,kBAAkB;CACnB,CAAC"}
package/lib/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  declare const _default: {};
2
- export = _default;
2
+ export default _default;
package/lib/index.js CHANGED
@@ -1,9 +1,8 @@
1
- "use strict";
2
1
  /*
3
2
  * Copyright (c) 2021, salesforce.com, inc.
4
3
  * All rights reserved.
5
4
  * Licensed under the BSD 3-Clause license.
6
5
  * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
7
6
  */
8
- module.exports = {};
7
+ export default {};
9
8
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;AAEH,iBAAS,EAAE,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAe,EAAE,CAAC"}
@@ -1,4 +1,4 @@
1
- import { IOptions } from 'js2xmlparser/lib/options';
1
+ import { IOptions } from 'js2xmlparser/lib/options.js';
2
2
  import { CustomObject, CustomField } from 'jsforce/api/metadata';
3
3
  import { JsonMap } from '@salesforce/ts-types';
4
4
  interface WriteJSONasXMLInputs {
@@ -1,14 +1,11 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseXml = exports.convertJsonToXml = void 0;
4
1
  /*
5
2
  * Copyright (c) 2020, salesforce.com, inc.
6
3
  * All rights reserved.
7
4
  * Licensed under the BSD 3-Clause license.
8
5
  * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
9
6
  */
10
- const jsToXml = require("js2xmlparser");
11
- const fast_xml_parser_1 = require("fast-xml-parser");
7
+ import * as jsToXml from 'js2xmlparser';
8
+ import { XMLParser } from 'fast-xml-parser';
12
9
  const standardOptions = {
13
10
  declaration: {
14
11
  include: true,
@@ -20,7 +17,6 @@ const standardOptions = {
20
17
  },
21
18
  };
22
19
  const convertJsonToXml = ({ json, type, options = standardOptions }) => jsToXml.parse(type, fixExistingDollarSign(json), options);
23
- exports.convertJsonToXml = convertJsonToXml;
24
20
  const fixExistingDollarSign = (existing) => {
25
21
  const existingCopy = { ...existing };
26
22
  if ('$' in existingCopy) {
@@ -31,8 +27,8 @@ const fixExistingDollarSign = (existing) => {
31
27
  return existingCopy;
32
28
  };
33
29
  const parseXml = (fileString, mainNodeName) => {
34
- const parser = new fast_xml_parser_1.XMLParser();
30
+ const parser = new XMLParser();
35
31
  return parser.parse(fileString)[mainNodeName];
36
32
  };
37
- exports.parseXml = parseXml;
33
+ export { convertJsonToXml, parseXml };
38
34
  //# sourceMappingURL=convert.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"convert.js","sourceRoot":"","sources":["../../src/shared/convert.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,wCAAwC;AACxC,qDAA4C;AAK5C,MAAM,eAAe,GAAa;IAChC,WAAW,EAAE;QACX,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,OAAO;QACjB,OAAO,EAAE,KAAK;KACf;IACD,MAAM,EAAE;QACN,YAAY,EAAE,IAAI;KACnB;CACF,CAAC;AAQF,MAAM,gBAAgB,GAAG,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,GAAG,eAAe,EAAwB,EAAU,EAAE,CACnG,OAAO,CAAC,KAAK,CAAC,IAAI,EAA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AAY,GAAG,EAAE,GAAG,QAAQ,EAAE,CAAC;IACrC,IAAI,GAAG,IAAI,YAAY,EAAE;QACvB,MAAM,IAAI,GAAG,YAAY,CAAC,CAAC,CAAC;QAC5B,OAAO,YAAY,CAAC,CAAC,CAAC;QACtB,YAAY,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;KAC1B;IACD,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC;AAEF,MAAM,QAAQ,GAAG,CAAI,UAAkB,EAAE,YAAoB,EAAK,EAAE;IAClE,MAAM,MAAM,GAAG,IAAI,SAAS,EAAE,CAAC;IAC/B,OAAQ,MAAM,CAAC,KAAK,CAAC,UAAU,CAAqC,CAAC,YAAY,CAAC,CAAC;AACrF,CAAC,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,CAAC"}
@@ -1,24 +1,21 @@
1
- "use strict";
2
1
  /*
3
2
  * Copyright (c) 2020, salesforce.com, inc.
4
3
  * All rights reserved.
5
4
  * Licensed under the BSD 3-Clause license.
6
5
  * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
7
6
  */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.isTabsFolder = exports.isObjectsFolder = exports.labelValidation = void 0;
10
- const path_1 = require("path");
11
- const core_1 = require("@salesforce/core");
12
- core_1.Messages.importMessagesDirectory(__dirname);
13
- const messages = core_1.Messages.loadMessages('@salesforce/plugin-sobject', 'flags');
7
+ import { sep, resolve, dirname } from 'node:path';
8
+ import { fileURLToPath } from 'node:url';
9
+ import { Messages, SfError } from '@salesforce/core';
10
+ Messages.importMessagesDirectory(dirname(fileURLToPath(import.meta.url)));
11
+ const messages = Messages.loadMessages('@salesforce/plugin-sobject', 'flags');
14
12
  // eslint-disable-next-line @typescript-eslint/require-await
15
- const labelValidation = async (label) => {
13
+ export const labelValidation = async (label) => {
16
14
  if (label.length < 3) {
17
- throw new core_1.SfError(messages.getMessage('error.labelLength', [label]));
15
+ throw new SfError(messages.getMessage('error.labelLength', [label]));
18
16
  }
19
17
  return label;
20
18
  };
21
- exports.labelValidation = labelValidation;
22
19
  /**
23
20
  * Validates that a path contains /objects/ and at least one directory beyond that
24
21
  *
@@ -26,15 +23,14 @@ exports.labelValidation = labelValidation;
26
23
  * @returns true if valid
27
24
  */
28
25
  // eslint-disable-next-line @typescript-eslint/require-await
29
- const isObjectsFolder = async (path) => {
30
- const pathParts = (0, path_1.resolve)(path.trim()).split(path_1.sep);
26
+ export const isObjectsFolder = async (path) => {
27
+ const pathParts = resolve(path.trim()).split(sep);
31
28
  // has /objects/ AND objects is not the last item (there must be some child)
32
29
  if (pathParts.includes('objects') && pathParts[pathParts.length - 1] !== 'objects') {
33
30
  return path;
34
31
  }
35
- throw new core_1.SfError(messages.getMessage('error.objectDirectory', [path]));
32
+ throw new SfError(messages.getMessage('error.objectDirectory', [path]));
36
33
  };
37
- exports.isObjectsFolder = isObjectsFolder;
38
34
  /**
39
35
  * Validates that a path ends in /tabs
40
36
  *
@@ -42,13 +38,12 @@ exports.isObjectsFolder = isObjectsFolder;
42
38
  * @returns true if valid
43
39
  */
44
40
  // eslint-disable-next-line @typescript-eslint/require-await
45
- const isTabsFolder = async (path) => {
41
+ export const isTabsFolder = async (path) => {
46
42
  // resolve will remove trailing separator
47
- const trimmed = (0, path_1.resolve)(path.trim());
43
+ const trimmed = resolve(path.trim());
48
44
  if (trimmed.endsWith('tabs')) {
49
45
  return trimmed;
50
46
  }
51
- throw new core_1.SfError(messages.getMessage('error.tabsDirectory', [path]));
47
+ throw new SfError(messages.getMessage('error.tabsDirectory', [path]));
52
48
  };
53
- exports.isTabsFolder = isTabsFolder;
54
49
  //# sourceMappingURL=flags.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"flags.js","sourceRoot":"","sources":["../../src/shared/flags.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,+BAAoC;AACpC,2CAAqD;AAErD,eAAQ,CAAC,uBAAuB,CAAC,SAA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AC,QAAQ,CAAC,UAAU,CAAC,uBAAuB,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAC1E,CAAC,CAAC;AAEF;;;;;GAKG;AACH,4DAA4D;AAC5D,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,EAAE,IAAY,EAAmB,EAAE;IAClE,yCAAyC;IACzC,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;IACrC,IAAI,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;QAC5B,OAAO,OAAO,CAAC;KAChB;IACD,MAAM,IAAI,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,qBAAqB,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACxE,CAAC,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { CustomObject } from 'jsforce/api/metadata';
2
- import { SaveableCustomObject, SaveablePlatformEvent } from './types';
2
+ import { SaveableCustomObject, SaveablePlatformEvent } from './types.js';
3
3
  /**
4
4
  * @param targetPaths typically your pkgDirs or project path
5
5
  * @returns directories that end in `/objects/`
package/lib/shared/fs.js CHANGED
@@ -1,19 +1,16 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.writeObjectFile = exports.getObjectXmlByFolderAsJson = exports.getObjectDirectories = exports.getDirectoriesThatContainObjects = void 0;
4
1
  /*
5
2
  * Copyright (c) 2020, salesforce.com, inc.
6
3
  * All rights reserved.
7
4
  * Licensed under the BSD 3-Clause license.
8
5
  * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
9
6
  */
10
- const path = require("path");
11
- const fs = require("fs");
12
- const fg = require("fast-glob");
13
- const convert_1 = require("./convert");
7
+ import path from 'node:path';
8
+ import fs from 'node:fs';
9
+ import fg from 'fast-glob';
10
+ import { convertJsonToXml, parseXml } from './convert.js';
14
11
  const getObjectXmlByPathAsJson = async (objectFilePath) => {
15
12
  const xml = await fs.promises.readFile(objectFilePath, 'utf8');
16
- return (0, convert_1.parseXml)(xml, 'CustomObject');
13
+ return parseXml(xml, 'CustomObject');
17
14
  };
18
15
  /** globs don't support windows path, but the input might be */
19
16
  const ensurePosixPath = (filePath) => filePath.split(path.sep).join(path.posix.sep);
@@ -21,41 +18,37 @@ const ensurePosixPath = (filePath) => filePath.split(path.sep).join(path.posix.s
21
18
  * @param targetPaths typically your pkgDirs or project path
22
19
  * @returns directories that end in `/objects/`
23
20
  */
24
- const getDirectoriesThatContainObjects = async (targetPaths) => {
21
+ export const getDirectoriesThatContainObjects = async (targetPaths) => {
25
22
  const globs = targetPaths.map((p) => `${ensurePosixPath(p)}/**/objects/`);
26
23
  return (await fg(globs, { onlyDirectories: true })).map((dir) => path.normalize(dir));
27
24
  };
28
- exports.getDirectoriesThatContainObjects = getDirectoriesThatContainObjects;
29
25
  /**
30
26
  * @param targetPaths typically your pkgDirs or project path
31
27
  * @returns directories that are children of `/objects/` like `force-app/main/default/objects/Foo__c`
32
28
  */
33
- const getObjectDirectories = async (targetPaths) => {
29
+ export const getObjectDirectories = async (targetPaths) => {
34
30
  const globs = targetPaths.map((p) => `${ensurePosixPath(p)}/**/objects/*`);
35
31
  return (await fg(globs, { onlyDirectories: true })).map((dir) => path.normalize(dir));
36
32
  };
37
- exports.getObjectDirectories = getObjectDirectories;
38
33
  /**
39
34
  * @param folder folder path to the object name (ex: `force-app/main/default/objects/Account`)
40
35
  * @returns CustomObject in json
41
36
  */
42
- const getObjectXmlByFolderAsJson = async (folder) => {
37
+ export const getObjectXmlByFolderAsJson = async (folder) => {
43
38
  const globs = `${ensurePosixPath(folder)}/*.object-meta.xml`;
44
39
  const [objectMetaPath] = await fg(globs);
45
40
  return getObjectXmlByPathAsJson(objectMetaPath);
46
41
  };
47
- exports.getObjectXmlByFolderAsJson = getObjectXmlByFolderAsJson;
48
42
  /**
49
43
  *
50
44
  * @returns path where the object was written
51
45
  */
52
- const writeObjectFile = async (objectDirectory, object) => {
46
+ export const writeObjectFile = async (objectDirectory, object) => {
53
47
  if (!object.fullName)
54
48
  throw new Error('object.fullName is required to write an object file');
55
49
  await fs.promises.mkdir(path.join(objectDirectory, object.fullName), { recursive: true });
56
50
  const targetFile = path.join(objectDirectory, object.fullName, `${object.fullName}.object-meta.xml`);
57
- await fs.promises.writeFile(targetFile, (0, convert_1.convertJsonToXml)({ json: object, type: 'CustomObject' }));
51
+ await fs.promises.writeFile(targetFile, convertJsonToXml({ json: object, type: 'CustomObject' }));
58
52
  return targetFile;
59
53
  };
60
- exports.writeObjectFile = writeObjectFile;
61
54
  //# sourceMappingURL=fs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fs.js","sourceRoot":"","sources":["../../src/shared/fs.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,6BAA6B;AAC7B,yBAAyB;AACzB,gCAAgC;AAEhC,uCAAuD;AAGvD,MAAM,wBAAwB,GAAG,KAAK,EAAE,cAAsB,EAAyB,EAAE;IACvF,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;IAC/D,OAAO,IAAA,kBAAQ,EAAe,GAAG,EAAE,cAAc,CAAC,CAAC;AACrD,CAAC,CAAC;AAEF,+DAA+D;AAC/D,MAAM,eAAe,GAAG,CAAC,QAAgB,EAAU,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AAEpG;;;GAGG;AACI,MAAM,gCAAgC,GAAG,KAAK,EAAE,WAAqB,EAAqB,EAAE;IACjG,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC;IAC1E,OAAO,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,eAAe,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,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC1F,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,MAAM,CAAC,QAAQ,EAAE,GAAG,MAAM,CAAC,QAAQ,kBAAkB,CAAC,CAAC;IACrG,MAAM,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,UAAU,EAAE,gBAAgB,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC,CAAC,CAAC;IAClG,OAAO,UAAU,CAAC;AACpB,CAAC,CAAC"}
@@ -1,11 +1,11 @@
1
1
  import { NamedPackageDir } from '@salesforce/core';
2
- import { Question, ListQuestion } from 'inquirer';
3
2
  import { ValueSet } from 'jsforce/api/metadata';
3
+ import { Prompter } from '@salesforce/sf-plugins-core';
4
4
  export declare const makeNameApiCompatible: (input: string) => string;
5
5
  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;
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
9
  export declare const descriptionPrompt: {
10
10
  type: string;
11
11
  message: string;
@@ -13,13 +13,13 @@ export declare const descriptionPrompt: {
13
13
  validate: (input: string) => true | string;
14
14
  };
15
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>;
16
+ export declare const namePrompts: (label: string) => Prompter.Answers[];
17
17
  /**
18
18
  *
19
19
  * @param packageDirs
20
20
  * @param name The "name" property of the Inquirer answer object. Supports use of the question for multiple scenarios
21
21
  */
22
- export declare const objectPrompt: (packageDirs: NamedPackageDir[], name?: 'object' | 'referenceTo', message?: string) => Promise<ListQuestion>;
22
+ export declare const objectPrompt: (packageDirs: NamedPackageDir[], name?: 'object' | 'referenceTo', message?: string) => Promise<Prompter.Answers>;
23
23
  export declare const integerValidation: (value: number, min: number, max: number) => true | string;
24
24
  /**
25
25
  * recursively keep adding picklist values until the user says to stop
@@ -1,13 +1,17 @@
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.loadMessages('@salesforce/plugin-sobject', 'prompts.shared');
9
- const makeNameApiCompatible = (input) => input.replace(/ /g, '').replace(/-/g, '_').replace(/_{2,}/g, '_');
10
- exports.makeNameApiCompatible = makeNameApiCompatible;
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 { dirname } from 'node:path';
8
+ import { fileURLToPath } from 'node:url';
9
+ import { Messages } from '@salesforce/core';
10
+ import { Prompter } from '@salesforce/sf-plugins-core';
11
+ import { getDirectoriesThatContainObjects, getObjectDirectories } from '../fs.js';
12
+ Messages.importMessagesDirectory(dirname(fileURLToPath(import.meta.url)));
13
+ const messages = Messages.loadMessages('@salesforce/plugin-sobject', 'prompts.shared');
14
+ export const makeNameApiCompatible = (input) => input.replace(/ /g, '').replace(/-/g, '_').replace(/_{2,}/g, '_');
11
15
  const getSuffix = (objectType) => {
12
16
  switch (objectType) {
13
17
  case 'CustomObject':
@@ -17,35 +21,32 @@ const getSuffix = (objectType) => {
17
21
  return '__e';
18
22
  }
19
23
  };
20
- const directoryPrompt = async (packageDirs) => ({
24
+ export const directoryPrompt = async (packageDirs) => ({
21
25
  type: 'list',
22
26
  message: messages.getMessage('directory'),
23
27
  name: 'directory',
24
- choices: await (0, fs_1.getDirectoriesThatContainObjects)(packageDirs.map((pd) => pd.path)),
28
+ choices: await getDirectoriesThatContainObjects(packageDirs.map((pd) => pd.path)),
25
29
  });
26
- exports.directoryPrompt = directoryPrompt;
27
- const pluralPrompt = (label) => ({
30
+ export const pluralPrompt = (label) => ({
28
31
  type: 'input',
29
32
  message: messages.getMessage('pluralLabel'),
30
33
  name: 'pluralLabel',
31
34
  default: `${label}s`,
32
35
  });
33
- exports.pluralPrompt = pluralPrompt;
34
- const apiNamePrompt = (label, objectType) => ({
36
+ export const apiNamePrompt = (label, objectType) => ({
35
37
  type: 'input',
36
38
  message: messages.getMessage('apiName'),
37
39
  name: 'fullName',
38
- default: `${(0, exports.makeNameApiCompatible)(label)}${getSuffix(objectType)}`,
40
+ default: `${makeNameApiCompatible(label)}${getSuffix(objectType)}`,
39
41
  });
40
- exports.apiNamePrompt = apiNamePrompt;
41
- exports.descriptionPrompt = {
42
+ export const descriptionPrompt = {
42
43
  type: 'input',
43
44
  message: messages.getMessage('description'),
44
45
  name: 'description',
45
46
  validate: (input) => (input.length ? true : messages.getMessage('error.noDescription')),
46
47
  };
47
48
  /** Ask about the name/type for the Name field, with a followup for AutoNumber format if AutoNumber is chosen */
48
- const namePrompts = (label) => [
49
+ export const namePrompts = (label) => [
49
50
  {
50
51
  type: 'input',
51
52
  message: messages.getMessage('nameFieldPrompts.label'),
@@ -67,39 +68,37 @@ const namePrompts = (label) => [
67
68
  default: `${label}-{0}`,
68
69
  },
69
70
  ];
70
- exports.namePrompts = namePrompts;
71
71
  /**
72
72
  *
73
73
  * @param packageDirs
74
74
  * @param name The "name" property of the Inquirer answer object. Supports use of the question for multiple scenarios
75
75
  */
76
- const objectPrompt = async (packageDirs, name = 'object', message = messages.getMessage('object')) => ({
76
+ export const objectPrompt = async (packageDirs, name = 'object', message = messages.getMessage('object')) => ({
77
77
  type: 'list',
78
78
  message,
79
79
  name,
80
- choices: (await (0, fs_1.getObjectDirectories)(packageDirs.map((pd) => pd.path)))
80
+ choices: (await getObjectDirectories(packageDirs.map((pd) => pd.path)))
81
81
  .sort()
82
82
  .map((objDir) => ({ value: objDir, name: objDir.split('/').pop() })),
83
83
  });
84
- exports.objectPrompt = objectPrompt;
85
- const integerValidation = (value, min, max) => {
84
+ export const integerValidation = (value, min, max) => {
86
85
  if (value < min)
87
86
  return messages.getMessage('numberValidationMin', [value, min]);
88
87
  if (value > max)
89
88
  return messages.getMessage('numberValidationMax', [value, max]);
90
89
  return true;
91
90
  };
92
- exports.integerValidation = integerValidation;
93
91
  /**
94
92
  * recursively keep adding picklist values until the user says to stop
95
93
  */
96
- const picklistPrompts = async () => {
94
+ export const picklistPrompts = async () => {
97
95
  const output = [];
98
96
  let keepAsking = true;
97
+ const prompter = new Prompter();
99
98
  while (keepAsking) {
100
99
  // the very definition of needing a loop for an await
101
100
  // eslint-disable-next-line no-await-in-loop
102
- const response = await (0, inquirer_1.prompt)({
101
+ const response = await prompter.prompt({
103
102
  type: 'input',
104
103
  name: 'picklistValue',
105
104
  validate: (input) => (output.find((v) => v.fullName === input) ? `${input} already exists` : true),
@@ -123,5 +122,4 @@ const picklistPrompts = async () => {
123
122
  },
124
123
  };
125
124
  };
126
- exports.picklistPrompts = picklistPrompts;
127
125
  //# sourceMappingURL=prompts.js.map
@@ -1 +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,YAAY,CAAC,4BAA4B,EAAE,gBAAgB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,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,iBAAiB,CAAC,CAAC,CAAC,IAAI,CAAC;YAC1G,OAAO,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,qBAAqB,CAAC;SAClH,CAAC,CAAC;QAEH,IAAI,QAAQ,CAAC,aAAa,KAAK,SAAS,IAAI,QAAQ,CAAC,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"}
@@ -1,24 +1,23 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.relationshipFieldPrompts = void 0;
4
1
  /*
5
2
  * Copyright (c) 2020, salesforce.com, inc.
6
3
  * All rights reserved.
7
4
  * Licensed under the BSD 3-Clause license.
8
5
  * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
9
6
  */
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.loadMessages('@salesforce/plugin-sobject', 'prompts.relationship');
17
- const relationshipFieldPrompts = async ({ type, packageDirs, childObjectFolderPath, }) => {
18
- const childObjectXml = await (0, fs_1.getObjectXmlByFolderAsJson)(childObjectFolderPath);
19
- const response = await (0, inquirer_1.prompt)([
7
+ import path, { dirname } from 'node:path';
8
+ import { fileURLToPath } from 'node:url';
9
+ import { Messages } from '@salesforce/core';
10
+ import { Prompter } from '@salesforce/sf-plugins-core';
11
+ import { getObjectXmlByFolderAsJson } from '../fs.js';
12
+ import { objectPrompt, makeNameApiCompatible } from './prompts.js';
13
+ Messages.importMessagesDirectory(dirname(fileURLToPath(import.meta.url)));
14
+ const messages = Messages.loadMessages('@salesforce/plugin-sobject', 'prompts.relationship');
15
+ export const relationshipFieldPrompts = async ({ type, packageDirs, childObjectFolderPath, }) => {
16
+ const prompter = new Prompter();
17
+ const childObjectXml = await getObjectXmlByFolderAsJson(childObjectFolderPath);
18
+ const response = await prompter.prompt([
20
19
  // prompt the user to select from objects in local source
21
- await (0, prompts_1.objectPrompt)(packageDirs, 'referenceTo', messages.getMessage('objectPrompt')),
20
+ await objectPrompt(packageDirs, 'referenceTo', messages.getMessage('objectPrompt')),
22
21
  {
23
22
  type: 'input',
24
23
  name: 'relationshipLabel',
@@ -29,7 +28,7 @@ const relationshipFieldPrompts = async ({ type, packageDirs, childObjectFolderPa
29
28
  type: 'input',
30
29
  name: 'relationshipName',
31
30
  message: 'Relationship name',
32
- default: (answers) => answers.relationshipLabel ? (0, prompts_1.makeNameApiCompatible)(answers.relationshipLabel) : undefined,
31
+ default: (answers) => answers.relationshipLabel ? makeNameApiCompatible(answers.relationshipLabel) : undefined,
33
32
  },
34
33
  // lookup-only
35
34
  {
@@ -74,5 +73,4 @@ const relationshipFieldPrompts = async ({ type, packageDirs, childObjectFolderPa
74
73
  referenceTo: response.referenceTo?.split(path.sep).pop(),
75
74
  };
76
75
  };
77
- exports.relationshipFieldPrompts = relationshipFieldPrompts;
78
76
  //# sourceMappingURL=relationshipField.js.map