@salesforce/core 3.31.18 → 3.32.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/lib/org/connection.js +1 -1
- package/lib/org/org.d.ts +5 -1
- package/lib/org/org.js +13 -1
- package/lib/schema/validator.js +1 -0
- package/lib/sfProject.js +24 -32
- package/package.json +1 -1
package/lib/org/connection.js
CHANGED
|
@@ -177,7 +177,7 @@ class Connection extends jsforce_1.Connection {
|
|
|
177
177
|
*/
|
|
178
178
|
async deployRecentValidation(options) {
|
|
179
179
|
// REST returns an object with an id property, SOAP returns the id as a string directly. That is now handled
|
|
180
|
-
// in jsforce, so we have to cast a string as
|
|
180
|
+
// in jsforce, so we have to cast a string as unknown as JsonCollection to support backwards compatibility.
|
|
181
181
|
return (await this.metadata.deployRecentValidation(options));
|
|
182
182
|
}
|
|
183
183
|
/**
|
package/lib/org/org.d.ts
CHANGED
|
@@ -357,8 +357,12 @@ export declare class Org extends AsyncOptionalCreatable<Org.Options> {
|
|
|
357
357
|
getFields(keys: Org.Fields[]): JsonMap;
|
|
358
358
|
/**
|
|
359
359
|
* Returns the JSForce connection for the org.
|
|
360
|
+
* side effect: If you pass it an apiVersion, it will set it on the Org
|
|
361
|
+
* so that future calls to getConnection() will also use that version.
|
|
362
|
+
*
|
|
363
|
+
* @param apiVersion The API version to use for the connection.
|
|
360
364
|
*/
|
|
361
|
-
getConnection(): Connection;
|
|
365
|
+
getConnection(apiVersion?: string): Connection;
|
|
362
366
|
supportsSourceTracking(): Promise<boolean>;
|
|
363
367
|
/**
|
|
364
368
|
* query SandboxProcess via sandbox name
|
package/lib/org/org.js
CHANGED
|
@@ -686,8 +686,20 @@ class Org extends kit_1.AsyncOptionalCreatable {
|
|
|
686
686
|
}
|
|
687
687
|
/**
|
|
688
688
|
* Returns the JSForce connection for the org.
|
|
689
|
+
* side effect: If you pass it an apiVersion, it will set it on the Org
|
|
690
|
+
* so that future calls to getConnection() will also use that version.
|
|
691
|
+
*
|
|
692
|
+
* @param apiVersion The API version to use for the connection.
|
|
689
693
|
*/
|
|
690
|
-
getConnection() {
|
|
694
|
+
getConnection(apiVersion) {
|
|
695
|
+
if (apiVersion) {
|
|
696
|
+
if (this.connection.getApiVersion() === apiVersion) {
|
|
697
|
+
this.logger.warn(`Default API version is already ${apiVersion}`);
|
|
698
|
+
}
|
|
699
|
+
else {
|
|
700
|
+
this.connection.setApiVersion(apiVersion);
|
|
701
|
+
}
|
|
702
|
+
}
|
|
691
703
|
return this.connection;
|
|
692
704
|
}
|
|
693
705
|
async supportsSourceTracking() {
|
package/lib/schema/validator.js
CHANGED
|
@@ -76,6 +76,7 @@ class SchemaValidator {
|
|
|
76
76
|
const externalSchemas = this.loadExternalSchemas(schema);
|
|
77
77
|
const ajv = new ajv_1.default({
|
|
78
78
|
allErrors: true,
|
|
79
|
+
allowUnionTypes: true,
|
|
79
80
|
schemas: externalSchemas,
|
|
80
81
|
useDefaults: true,
|
|
81
82
|
// TODO: We may someday want to enable strictSchema. This is disabled for now
|
package/lib/sfProject.js
CHANGED
|
@@ -59,13 +59,11 @@ class SfProjectJson extends configFile_1.ConfigFile {
|
|
|
59
59
|
async read() {
|
|
60
60
|
const contents = await super.read();
|
|
61
61
|
this.validateKeys();
|
|
62
|
-
await this.schemaValidate();
|
|
63
62
|
return contents;
|
|
64
63
|
}
|
|
65
64
|
readSync() {
|
|
66
65
|
const contents = super.readSync();
|
|
67
66
|
this.validateKeys();
|
|
68
|
-
this.schemaValidateSync();
|
|
69
67
|
return contents;
|
|
70
68
|
}
|
|
71
69
|
async write(newContents) {
|
|
@@ -73,7 +71,6 @@ class SfProjectJson extends configFile_1.ConfigFile {
|
|
|
73
71
|
this.setContents(newContents);
|
|
74
72
|
}
|
|
75
73
|
this.validateKeys();
|
|
76
|
-
await this.schemaValidate();
|
|
77
74
|
return super.write();
|
|
78
75
|
}
|
|
79
76
|
writeSync(newContents) {
|
|
@@ -81,7 +78,6 @@ class SfProjectJson extends configFile_1.ConfigFile {
|
|
|
81
78
|
this.setContents(newContents);
|
|
82
79
|
}
|
|
83
80
|
this.validateKeys();
|
|
84
|
-
this.schemaValidateSync();
|
|
85
81
|
return super.writeSync();
|
|
86
82
|
}
|
|
87
83
|
getContents() {
|
|
@@ -108,21 +104,19 @@ class SfProjectJson extends configFile_1.ConfigFile {
|
|
|
108
104
|
// read calls back into this method after necessarily setting this.hasRead=true
|
|
109
105
|
await this.read();
|
|
110
106
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
107
|
+
try {
|
|
108
|
+
const projectJsonSchemaPath = require.resolve('@salesforce/schemas/sfdx-project.schema.json');
|
|
109
|
+
const validator = new validator_1.SchemaValidator(this.logger, projectJsonSchemaPath);
|
|
110
|
+
await validator.validate(this.getContents());
|
|
111
|
+
}
|
|
112
|
+
catch (err) {
|
|
113
|
+
const error = err;
|
|
114
|
+
// Don't throw errors if the global isn't valid, but still warn the user.
|
|
115
|
+
if (kit_1.env.getBoolean('SFDX_PROJECT_JSON_VALIDATION', false) && !this.options.isGlobal) {
|
|
116
|
+
throw messages.createError('schemaValidationError', [this.getPath(), error.message], [this.getPath()], error);
|
|
116
117
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
// Don't throw errors if the global isn't valid, but still warn the user.
|
|
120
|
-
if (kit_1.env.getBoolean('SFDX_PROJECT_JSON_VALIDATION', false) && !this.options.isGlobal) {
|
|
121
|
-
throw messages.createError('schemaValidationError', [this.getPath(), error.message], [this.getPath()], error);
|
|
122
|
-
}
|
|
123
|
-
else {
|
|
124
|
-
this.logger.warn(messages.getMessage('schemaValidationError', [this.getPath(), error.message]));
|
|
125
|
-
}
|
|
118
|
+
else {
|
|
119
|
+
this.logger.warn(messages.getMessage('schemaValidationError', [this.getPath(), error.message]));
|
|
126
120
|
}
|
|
127
121
|
}
|
|
128
122
|
}
|
|
@@ -147,21 +141,19 @@ class SfProjectJson extends configFile_1.ConfigFile {
|
|
|
147
141
|
// read calls back into this method after necessarily setting this.hasRead=true
|
|
148
142
|
this.readSync();
|
|
149
143
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
144
|
+
try {
|
|
145
|
+
const projectJsonSchemaPath = require.resolve('@salesforce/schemas/sfdx-project.schema.json');
|
|
146
|
+
const validator = new validator_1.SchemaValidator(this.logger, projectJsonSchemaPath);
|
|
147
|
+
validator.validateSync(this.getContents());
|
|
148
|
+
}
|
|
149
|
+
catch (err) {
|
|
150
|
+
const error = err;
|
|
151
|
+
// Don't throw errors if the global isn't valid, but still warn the user.
|
|
152
|
+
if (kit_1.env.getBoolean('SFDX_PROJECT_JSON_VALIDATION', false) && !this.options.isGlobal) {
|
|
153
|
+
throw messages.createError('schemaValidationError', [this.getPath(), error.message], [this.getPath()], error);
|
|
155
154
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
// Don't throw errors if the global isn't valid, but still warn the user.
|
|
159
|
-
if (kit_1.env.getBoolean('SFDX_PROJECT_JSON_VALIDATION', false) && !this.options.isGlobal) {
|
|
160
|
-
throw messages.createError('schemaValidationError', [this.getPath(), error.message], [this.getPath()], error);
|
|
161
|
-
}
|
|
162
|
-
else {
|
|
163
|
-
this.logger.warn(messages.getMessage('schemaValidationError', [this.getPath(), error.message]));
|
|
164
|
-
}
|
|
155
|
+
else {
|
|
156
|
+
this.logger.warn(messages.getMessage('schemaValidationError', [this.getPath(), error.message]));
|
|
165
157
|
}
|
|
166
158
|
}
|
|
167
159
|
}
|