@salesforce/sf-plugins-core 1.21.6 → 1.21.7

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.
@@ -1,8 +1,8 @@
1
1
  export type IdFlagConfig = {
2
2
  /**
3
- * Can specify if the version must be 15 or 18 characters long. Leave blank to allow either 15 or 18.
3
+ * Can specify if the version must be 15 or 18 characters long or 'both'. Leave blank to allow either 15 or 18.
4
4
  */
5
- length?: 15 | 18;
5
+ length?: 15 | 18 | 'both';
6
6
  /**
7
7
  * If the ID belongs to a certain sobject type, specify the 3 character prefix.
8
8
  */
@@ -39,11 +39,12 @@ exports.salesforceIdFlag = core_1.Flags.custom({
39
39
  });
40
40
  const validate = (input, config) => {
41
41
  const { length, startsWith } = config ?? {};
42
- if (length && input.length !== length) {
43
- throw messages.createError('errors.InvalidIdLength', [length]);
44
- }
45
- if (!length && ![15, 18].includes(input.length)) {
46
- throw messages.createError('errors.InvalidIdLength', ['15 or 18']);
42
+ // If the flag doesn't specify a length or specifies "both", then let it accept both 15 or 18.
43
+ const allowedIdLength = (!length || length === 'both') ? [15, 18] : [length];
44
+ if (!allowedIdLength.includes(input.length)) {
45
+ throw messages.createError('errors.InvalidIdLength', [
46
+ allowedIdLength.join(` ${messages.getMessage('errors.InvalidIdLength.or')} `),
47
+ ]);
47
48
  }
48
49
  if (!core_2.sfdc.validateSalesforceId(input)) {
49
50
  throw messages.createError('errors.InvalidId');
@@ -14,6 +14,10 @@ This command is required to run from within a Salesforce project directory.
14
14
 
15
15
  The id must be %s characters.
16
16
 
17
+ # errors.InvalidIdLength.or
18
+
19
+ or
20
+
17
21
  # errors.InvalidId
18
22
 
19
23
  The id is invalid.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/sf-plugins-core",
3
- "version": "1.21.6",
3
+ "version": "1.21.7",
4
4
  "description": "Utils for writing deploy and retrieve plugins",
5
5
  "main": "lib/exported",
6
6
  "types": "lib/exported.d.ts",