@salesforce/core
Advanced tools
Comparing version 7.4.1 to 7.5.0
@@ -25,3 +25,3 @@ export { OAuth2Config } from '@jsforce/jsforce-node'; | ||
export { OrgConfigProperties, ORG_CONFIG_ALLOWED_PROPERTIES } from './org/orgConfigProperties'; | ||
export { PackageDir, NamedPackageDir, PackageDirDependency, SfProject, SfProjectJson } from './sfProject'; | ||
export { NamedPackageDir, SfProject, SfProjectJson } from './sfProject'; | ||
export { SchemaValidator } from './schema/validator'; | ||
@@ -28,0 +28,0 @@ export { SfError } from './sfError'; |
@@ -56,2 +56,3 @@ "use strict"; | ||
const packagesWithAncestors = (await projectJson.getPackageDirectories()) | ||
.filter(sfProject_1.isPackagingDirectory) | ||
// check that the package has any ancestor types (id or version) | ||
@@ -58,0 +59,0 @@ .filter((packageDir) => packageDir.ancestorId ?? packageDir.ancestorVersion); |
import { Dictionary, JsonMap, Nullable, Optional } from '@salesforce/ts-types'; | ||
import { PackageDir, ProjectJson as ProjectJsonSchema, PackagePackageDir } from '@salesforce/schemas'; | ||
import { ConfigFile } from './config/configFile'; | ||
import { ConfigContents } from './config/configStackTypes'; | ||
export type PackageDirDependency = { | ||
[k: string]: unknown; | ||
package: string; | ||
versionNumber?: string; | ||
}; | ||
export type PackageDir = { | ||
ancestorId?: string; | ||
ancestorVersion?: string; | ||
default?: boolean; | ||
definitionFile?: string; | ||
dependencies?: PackageDirDependency[]; | ||
includeProfileUserLicenses?: boolean; | ||
package?: string; | ||
packageMetadataAccess?: { | ||
permissionSets: string | string[]; | ||
permissionSetLicenses: string | string[]; | ||
}; | ||
path: string; | ||
postInstallScript?: string; | ||
postInstallUrl?: string; | ||
releaseNotesUrl?: string; | ||
scopeProfiles?: boolean; | ||
uninstallScript?: string; | ||
versionDescription?: string; | ||
versionName?: string; | ||
versionNumber?: string; | ||
unpackagedMetadata?: { | ||
path: string; | ||
}; | ||
seedMetadata?: { | ||
path: string; | ||
}; | ||
}; | ||
export type NamedPackageDir = PackageDir & { | ||
type NameAndFullPath = { | ||
/** | ||
@@ -47,16 +15,5 @@ * The [normalized](https://nodejs.org/api/path.html#path_path_normalize_path) path used as the package name. | ||
}; | ||
export type ProjectJson = ConfigContents & { | ||
packageDirectories: PackageDir[]; | ||
namespace?: string; | ||
sourceApiVersion?: string; | ||
sfdcLoginUrl?: string; | ||
signupTargetLoginUrl?: string; | ||
oauthLocalPort?: number; | ||
plugins?: { | ||
[k: string]: unknown; | ||
}; | ||
packageAliases?: { | ||
[k: string]: string; | ||
}; | ||
}; | ||
export type NamedPackagingDir = PackagePackageDir & NameAndFullPath; | ||
export type NamedPackageDir = PackageDir & NameAndFullPath; | ||
export type ProjectJson = ConfigContents & ProjectJsonSchema; | ||
/** | ||
@@ -80,2 +37,3 @@ * The sfdx-project.json config object. This file determines if a folder is a valid sfdx project. | ||
export declare class SfProjectJson extends ConfigFile<ConfigFile.Options, ProjectJson> { | ||
/** json properties that are uppercase, or allow uppercase keys inside them */ | ||
static BLOCKLIST: string[]; | ||
@@ -165,3 +123,3 @@ static getFileName(): string; | ||
*/ | ||
addPackageDirectory(packageDir: NamedPackageDir): void; | ||
addPackageDirectory(packageDir: PackageDir): void; | ||
private doesPackageExist; | ||
@@ -364,1 +322,6 @@ private validateKeys; | ||
} | ||
/** differentiate between the Base PackageDir (path, maybe default) and the Packaging version (package and maybe a LOT of other fields) by whether is has the `package` property */ | ||
export declare const isPackagingDirectory: (packageDir: PackageDir) => packageDir is PackagePackageDir; | ||
/** differentiate between the Base PackageDir (path, maybe default) and the Packaging version (package and maybe a LOT of other fields) by whether is has the `package` property */ | ||
export declare const isNamedPackagingDirectory: (packageDir: NamedPackageDir) => packageDir is NamedPackagingDir; | ||
export {}; |
@@ -26,3 +26,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.SfProject = exports.SfProjectJson = void 0; | ||
exports.isNamedPackagingDirectory = exports.isPackagingDirectory = exports.SfProject = exports.SfProjectJson = void 0; | ||
/* | ||
@@ -48,3 +48,2 @@ * Copyright (c) 2020, salesforce.com, inc. | ||
const messages = new messages_1.Messages('@salesforce/core', 'config', new Map([["unknownConfigKey", "Unknown config name: %s."], ["deprecatedConfigKey", "Deprecated config name: %s. Please use %s instead."], ["invalidWrite", "The writeSync method is not allowed on SfdxConfig. Use the async write method instead."], ["invalidConfigValue", "Invalid config value: %s."], ["invalidInstanceUrl", "Specify a valid Salesforce instance URL."], ["invalidApiVersion", "Specify a valid Salesforce API version, for example, 42.0."], ["invalidCustomOrgMetadataTemplates", "Specify a valid repository URL or directory for the custom org metadata templates."], ["invalidIsvDebuggerSid", "Specify a valid Debugger SID."], ["invalidIsvDebuggerUrl", "Specify a valid Debugger URL."], ["invalidNumberConfigValue", "Specify a valid positive integer, for example, 150000."], ["invalidBooleanConfigValue", "The config value can only be set to true or false."], ["invalidProjectWorkspace", "This directory does not contain a valid Salesforce DX project."], ["schemaValidationError", "The config file \"%s\" is not schema valid.\nDue to: %s"], ["schemaValidationError.actions", ["Fix the invalid entries at %s."]], ["missingDefaultPath", "In sfdx-project.json, be sure to specify which package directory (path) is the default. Example: `[{ \"path\": \"packageDirectory1\", \"default\": true }, { \"path\": \"packageDirectory2\" }]`"], ["missingPackageDirectory", "The path \"%s\", specified in sfdx-project.json, does not exist. Be sure this directory is included in your project root."], ["invalidPackageDirectory", "The path \"%s\", specified in sfdx-project.json, must be indicated as a relative path to the project root."], ["multipleDefaultPaths", "In sfdx-project.json, indicate only one package directory (path) as the default."], ["singleNonDefaultPackage", "The sfdx-project.json file must include one, and only one, default package directory (path). Because your sfdx-project.json file contains only one package directory, it must be the default. Remove the `\"default\": false` key and try again."], ["target-org", "Username or alias of the org that all commands run against by default. (sf only)"], ["target-dev-hub", "Username or alias of your default Dev Hub org. (sf only)"], ["defaultUsername", "Username or alias of the org that all commands run against by default. (sfdx only)"], ["defaultDevHubUsername", "Username or alias of your default Dev Hub org. (sfdx only)"], ["isvDebuggerSid", "ISV debugger SID (sfdx only)"], ["isvDebuggerUrl", "ISV debugger URL (sfdx only)"], ["org-isv-debugger-sid", "ISV debugger SID."], ["org-isv-debugger-url", "ISV debugger URL."], ["apiVersion", "API version of your project. Default: API version of your Dev Hub org. (sfdx only)"], ["org-api-version", "API version of your project. Default: API version of your Dev Hub org."], ["disableTelemetry", "Disables the collection of usage and user environment information, etc. Default: false. (sfdx only)"], ["disable-telemetry", "Disables the collection of usage and user environment information, etc. Default: false."], ["maxQueryLimit", "Maximum number of Salesforce records returned by a CLI command. Default: 10,000. (sfdx only)"], ["org-max-query-limit", "Maximum number of Salesforce records returned by a CLI command. Default: 10,000."], ["restDeploy", "Whether deployments use the Metadata REST API (true) or SOAP API (false, default value). (sfdx only)"], ["instanceUrl", "URL of the Salesforce instance hosting your org. Default: https://login.salesforce.com. (sfdx only)"], ["org-instance-url", "URL of the Salesforce instance hosting your org. Default: https://login.salesforce.com."], ["customOrgMetadataTemplates", "A valid repository URL or directory for the custom org metadata templates."], ["org-custom-metadata-templates", "A valid repository URL or directory for the custom org metadata templates."], ["org-capitalize-record-types", "Whether record types are capitalized on scratch org creation."], ["invalidId", "The given id %s is not a valid 15 or 18 character Salesforce ID."]])); | ||
const coreMessages = new messages_1.Messages('@salesforce/core', 'core', new Map([["authInfoCreationError", "Must pass a username and/or OAuth options when creating an AuthInfo instance."], ["authInfoOverwriteError", "Cannot create an AuthInfo instance that will overwrite existing auth data."], ["authInfoOverwriteError.actions", ["Create the AuthInfo instance using existing auth data by just passing the username. E.g., `AuthInfo.create({ username: 'my@user.org' });`."]], ["authCodeExchangeError", "Error authenticating with auth code due to: %s"], ["authCodeUsernameRetrievalError", "Could not retrieve the username after successful auth code exchange.\n\nDue to: %s"], ["jwtAuthError", "Error authenticating with JWT config due to: %s"], ["jwtAuthErrors", "Error authenticating with JWT.\nErrors encountered:\n%s"], ["refreshTokenAuthError", "Error authenticating with the refresh token due to: %s"], ["orgDataNotAvailableError", "An attempt to refresh the authentication token failed with a 'Data Not Found Error'. The org identified by username %s does not appear to exist. Likely cause is that the org was deleted by another user or has expired."], ["orgDataNotAvailableError.actions", ["Run `sfdx force:org:list --clean` to remove stale org authentications.", "Use `sfdx force:config:set` to update the defaultusername.", "Use `sfdx force:org:create` to create a new org.", "Use `sfdx auth` to authenticate an existing org."]], ["namedOrgNotFound", "No authorization information found for %s."], ["noAliasesFound", "Nothing to set."], ["invalidFormat", "Setting aliases must be in the format <key>=<value> but found: [%s]."], ["invalidJsonCasing", "All JSON input must have heads down camelcase keys. E.g., `{ sfdcLoginUrl: \"https://login.salesforce.com\" }`\nFound \"%s\" at %s"], ["missingClientId", "Client ID is required for JWT authentication."]])); | ||
/** | ||
@@ -68,2 +67,3 @@ * The sfdx-project.json config object. This file determines if a folder is a valid sfdx project. | ||
class SfProjectJson extends configFile_1.ConfigFile { | ||
/** json properties that are uppercase, or allow uppercase keys inside them */ | ||
static BLOCKLIST = ['packageAliases']; | ||
@@ -288,12 +288,3 @@ static getFileName() { | ||
addPackageDirectory(packageDir) { | ||
// there is no notion of uniqueness in package directory entries | ||
// so an attempt of matching an existing entry is a bit convoluted | ||
// an entry w/o a package or id is considered a directory entry for which a package has yet to be created | ||
// so first attempt is to find a matching dir entry that where path is the same and id and package are not present | ||
// if that fails, then find a matching dir entry package is present and is same as the new entry | ||
const dirIndex = this.getContents().packageDirectories.findIndex((pd) => { | ||
const withId = pd; | ||
return ((withId.path === packageDir.path && !withId.id && !withId.package) || | ||
(!!packageDir.package && packageDir.package === withId.package)); | ||
}); | ||
const dirIndex = this.getContents().packageDirectories.findIndex(findPackageDir(packageDir)); | ||
// merge new package dir with existing entry, if present | ||
@@ -308,2 +299,3 @@ const packageDirEntry = Object.assign({}, dirIndex > -1 ? this.getContents().packageDirectories[dirIndex] : packageDir, packageDir); | ||
} | ||
// keep it because testSetup stubs it! | ||
// eslint-disable-next-line class-methods-use-this | ||
@@ -314,7 +306,3 @@ doesPackageExist(packagePath) { | ||
validateKeys() { | ||
// Verify that the configObject does not have upper case keys; throw if it does. Must be heads down camel case. | ||
const upperCaseKey = (0, findUppercaseKeys_1.findUpperCaseKeys)(this.toObject(), SfProjectJson.BLOCKLIST); | ||
if (upperCaseKey) { | ||
throw coreMessages.createError('invalidJsonCasing', [upperCaseKey, this.getPath()]); | ||
} | ||
(0, findUppercaseKeys_1.ensureNoUppercaseKeys)(this.getPath())(SfProjectJson.BLOCKLIST)(this.toObject()); | ||
} | ||
@@ -529,3 +517,5 @@ } | ||
const packageDir = this.getPackageFromPath(path); | ||
return packageDir ? packageDir.package ?? packageDir.path : undefined; | ||
if (!packageDir) | ||
return undefined; | ||
return (0, exports.isNamedPackagingDirectory)(packageDir) ? packageDir.package : packageDir.path; | ||
} | ||
@@ -676,2 +666,19 @@ /** | ||
exports.SfProject = SfProject; | ||
/** differentiate between the Base PackageDir (path, maybe default) and the Packaging version (package and maybe a LOT of other fields) by whether is has the `package` property */ | ||
const isPackagingDirectory = (packageDir) => isPackagingDir(packageDir); | ||
exports.isPackagingDirectory = isPackagingDirectory; | ||
/** differentiate between the Base PackageDir (path, maybe default) and the Packaging version (package and maybe a LOT of other fields) by whether is has the `package` property */ | ||
const isNamedPackagingDirectory = (packageDir) => isPackagingDir(packageDir); | ||
exports.isNamedPackagingDirectory = isNamedPackagingDirectory; | ||
const isPackagingDir = (packageDir) => 'package' in packageDir && typeof packageDir.package === 'string'; | ||
/** | ||
* there is no notion of uniqueness in package directory entries | ||
* so an attempt of matching an existing entry is a bit convoluted | ||
*/ | ||
const findPackageDir = (target) => (potentialMatch) => | ||
// an entry w/o a package or id is considered a directory entry for which a package has yet to be created | ||
// find a matching dir entry that where path is the same and id and package are not present | ||
(potentialMatch.path === target.path && !('id' in potentialMatch) && !(0, exports.isPackagingDirectory)(potentialMatch)) || | ||
// if that fails, then find a matching dir entry package is present and is same as the new entry | ||
((0, exports.isPackagingDirectory)(target) && (0, exports.isPackagingDirectory)(potentialMatch) && target.package === potentialMatch.package); | ||
//# sourceMappingURL=sfProject.js.map |
@@ -1,2 +0,3 @@ | ||
import { JsonMap, Optional } from '@salesforce/ts-types'; | ||
export declare const findUpperCaseKeys: (data?: JsonMap, sectionBlocklist?: string[]) => Optional<string>; | ||
import { JsonMap } from '@salesforce/ts-types'; | ||
/** will throw on any upperCase unless they are present in the allowList. Recursively searches the object, returning valid keys */ | ||
export declare const ensureNoUppercaseKeys: (path: string) => (allowList?: string[]) => (data: JsonMap) => string[]; |
@@ -9,22 +9,19 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.findUpperCaseKeys = void 0; | ||
exports.ensureNoUppercaseKeys = void 0; | ||
const strict_1 = require("node:assert/strict"); | ||
const ts_types_1 = require("@salesforce/ts-types"); | ||
const kit_1 = require("@salesforce/kit"); | ||
const findUpperCaseKeys = (data, sectionBlocklist = []) => { | ||
let key; | ||
(0, kit_1.findKey)(data, (val, k) => { | ||
if (/^[A-Z]/.test(k)) { | ||
key = k; | ||
} | ||
else if ((0, ts_types_1.isJsonMap)(val)) { | ||
if (sectionBlocklist.includes(k)) { | ||
return key; | ||
} | ||
key = (0, exports.findUpperCaseKeys)((0, ts_types_1.asJsonMap)(val)); | ||
} | ||
return key; | ||
}); | ||
return key; | ||
const messages_1 = require("../messages"); | ||
; | ||
const coreMessages = new messages_1.Messages('@salesforce/core', 'core', new Map([["authInfoCreationError", "Must pass a username and/or OAuth options when creating an AuthInfo instance."], ["authInfoOverwriteError", "Cannot create an AuthInfo instance that will overwrite existing auth data."], ["authInfoOverwriteError.actions", ["Create the AuthInfo instance using existing auth data by just passing the username. E.g., `AuthInfo.create({ username: 'my@user.org' });`."]], ["authCodeExchangeError", "Error authenticating with auth code due to: %s"], ["authCodeUsernameRetrievalError", "Could not retrieve the username after successful auth code exchange.\n\nDue to: %s"], ["jwtAuthError", "Error authenticating with JWT config due to: %s"], ["jwtAuthErrors", "Error authenticating with JWT.\nErrors encountered:\n%s"], ["refreshTokenAuthError", "Error authenticating with the refresh token due to: %s"], ["orgDataNotAvailableError", "An attempt to refresh the authentication token failed with a 'Data Not Found Error'. The org identified by username %s does not appear to exist. Likely cause is that the org was deleted by another user or has expired."], ["orgDataNotAvailableError.actions", ["Run `sfdx force:org:list --clean` to remove stale org authentications.", "Use `sfdx force:config:set` to update the defaultusername.", "Use `sfdx force:org:create` to create a new org.", "Use `sfdx auth` to authenticate an existing org."]], ["namedOrgNotFound", "No authorization information found for %s."], ["noAliasesFound", "Nothing to set."], ["invalidFormat", "Setting aliases must be in the format <key>=<value> but found: [%s]."], ["invalidJsonCasing", "All JSON input must have heads down camelcase keys. E.g., `{ sfdcLoginUrl: \"https://login.salesforce.com\" }`\nFound \"%s\" at %s"], ["missingClientId", "Client ID is required for JWT authentication."]])); | ||
/** will throw on any upperCase unless they are present in the allowList. Recursively searches the object, returning valid keys */ | ||
const ensureNoUppercaseKeys = (path) => (allowList = []) => (data) => { | ||
const keys = getKeys(data, allowList); | ||
const upperCaseKeys = keys.filter((key) => /^[A-Z]/.test(key)).join(', '); | ||
(0, strict_1.strictEqual)(upperCaseKeys.length, 0, coreMessages.getMessage('invalidJsonCasing', [upperCaseKeys, path])); | ||
return keys; | ||
}; | ||
exports.findUpperCaseKeys = findUpperCaseKeys; | ||
exports.ensureNoUppercaseKeys = ensureNoUppercaseKeys; | ||
const getKeys = (data, allowList) => Object.entries(data) | ||
.filter(([k]) => !allowList.includes(k)) | ||
.flatMap(([key, value]) => ((0, ts_types_1.isJsonMap)(value) ? [key, ...getKeys(value, allowList)] : [key])); | ||
//# sourceMappingURL=findUppercaseKeys.js.map |
{ | ||
"name": "@salesforce/core", | ||
"version": "7.4.1", | ||
"version": "7.5.0", | ||
"description": "Core libraries to interact with SFDX projects, orgs, and APIs.", | ||
@@ -56,5 +56,5 @@ "main": "lib/index", | ||
"@jsforce/jsforce-node": "^3.2.0", | ||
"@salesforce/kit": "^3.1.2", | ||
"@salesforce/kit": "^3.1.6", | ||
"@salesforce/schemas": "^1.9.0", | ||
"@salesforce/ts-types": "^2.0.9", | ||
"@salesforce/ts-types": "^2.0.10", | ||
"ajv": "^8.15.0", | ||
@@ -68,5 +68,5 @@ "change-case": "^4.1.2", | ||
"jszip": "3.10.1", | ||
"pino": "^8.21.0", | ||
"pino": "^9.2.0", | ||
"pino-abstract-transport": "^1.2.0", | ||
"pino-pretty": "^10.3.1", | ||
"pino-pretty": "^11.2.1", | ||
"proper-lockfile": "^4.1.2", | ||
@@ -77,4 +77,4 @@ "semver": "^7.6.2", | ||
"devDependencies": { | ||
"@salesforce/dev-scripts": "^8.5.0", | ||
"@salesforce/ts-sinon": "^1.4.19", | ||
"@salesforce/dev-scripts": "^10.1.1", | ||
"@salesforce/ts-sinon": "^1.4.22", | ||
"@types/benchmark": "^2.1.5", | ||
@@ -81,0 +81,0 @@ "@types/chai-string": "^1.4.5", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1037634
22056
1
+ Addedpino@9.4.0(transitive)
+ Addedpino-pretty@11.2.2(transitive)
+ Addedpino-std-serializers@7.0.0(transitive)
+ Addedprocess-warning@4.0.0(transitive)
+ Addedsonic-boom@4.1.0(transitive)
+ Addedthread-stream@3.1.0(transitive)
- Removedpino@8.21.0(transitive)
- Removedpino-pretty@10.3.1(transitive)
- Removedpino-std-serializers@6.2.2(transitive)
- Removedprocess-warning@3.0.0(transitive)
- Removedsonic-boom@3.8.1(transitive)
- Removedthread-stream@2.7.0(transitive)
Updated@salesforce/kit@^3.1.6
Updated@salesforce/ts-types@^2.0.10
Updatedpino@^9.2.0
Updatedpino-pretty@^11.2.1