@salesforce/core 3.7.1 → 3.7.5
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/CHANGELOG.md +96 -2
- package/LICENSE.txt +1 -1
- package/lib/config/config.js +15 -15
- package/lib/config/configAggregator.js +4 -4
- package/lib/config/configFile.js +9 -9
- package/lib/config/configStore.js +12 -13
- package/lib/config/envVars.d.ts +20 -5
- package/lib/config/envVars.js +75 -10
- package/lib/config/keychainConfig.js +1 -1
- package/lib/crypto/crypto.js +6 -6
- package/lib/crypto/keyChainImpl.js +6 -5
- package/lib/crypto/secureBuffer.js +1 -1
- package/lib/deviceOauthService.js +5 -4
- package/lib/exported.d.ts +2 -2
- package/lib/exported.js +6 -2
- package/lib/globalInfo/globalInfoConfig.js +1 -1
- package/lib/globalInfo/sfdxDataHandler.js +11 -11
- package/lib/lifecycleEvents.d.ts +38 -1
- package/lib/lifecycleEvents.js +73 -2
- package/lib/logger.js +13 -12
- package/lib/messages.js +10 -9
- package/lib/org/authInfo.d.ts +2 -6
- package/lib/org/authInfo.js +44 -41
- package/lib/org/connection.js +14 -11
- package/lib/org/org.d.ts +121 -9
- package/lib/org/org.js +373 -36
- package/lib/org/orgConfigProperties.js +1 -1
- package/lib/org/permissionSetAssignment.js +3 -3
- package/lib/org/user.js +20 -20
- package/lib/schema/printer.js +18 -18
- package/lib/schema/validator.js +8 -8
- package/lib/sfdxError.d.ts +1 -1
- package/lib/sfdxError.js +3 -2
- package/lib/sfdxProject.js +15 -13
- package/lib/status/myDomainResolver.js +3 -3
- package/lib/status/pollingClient.d.ts +0 -1
- package/lib/status/pollingClient.js +2 -2
- package/lib/status/streamingClient.d.ts +2 -3
- package/lib/status/streamingClient.js +16 -22
- package/lib/status/types.d.ts +89 -0
- package/lib/status/types.js +18 -0
- package/lib/testSetup.d.ts +3 -2
- package/lib/testSetup.js +25 -25
- package/lib/util/cache.js +3 -3
- package/lib/util/fs.js +12 -12
- package/lib/util/sfdc.js +3 -3
- package/lib/util/sfdcUrl.d.ts +2 -1
- package/lib/util/sfdcUrl.js +16 -8
- package/lib/webOAuthServer.js +7 -7
- package/messages/core.json +3 -3
- package/messages/core.md +1 -1
- package/messages/envVars.md +53 -13
- package/messages/org.md +36 -0
- package/package.json +39 -46
package/lib/org/user.js
CHANGED
|
@@ -84,18 +84,18 @@ async function retrieveUserFields(logger, username) {
|
|
|
84
84
|
const result = await connection.query(requiredFieldsFromAdminQuery);
|
|
85
85
|
logger.debug('Successfully retrieved the admin user for this org.');
|
|
86
86
|
if (result.totalSize === 1) {
|
|
87
|
-
const results = kit_1.mapKeys(result.records[0], (value, key) => kit_1.lowerFirst(key));
|
|
87
|
+
const results = (0, kit_1.mapKeys)(result.records[0], (value, key) => (0, kit_1.lowerFirst)(key));
|
|
88
88
|
const fields = {
|
|
89
|
-
id: ts_types_1.ensure(ts_types_1.getString(results, exports.REQUIRED_FIELDS.id)),
|
|
89
|
+
id: (0, ts_types_1.ensure)((0, ts_types_1.getString)(results, exports.REQUIRED_FIELDS.id)),
|
|
90
90
|
username,
|
|
91
|
-
alias: ts_types_1.ensure(ts_types_1.getString(results, exports.REQUIRED_FIELDS.alias)),
|
|
92
|
-
email: ts_types_1.ensure(ts_types_1.getString(results, exports.REQUIRED_FIELDS.email)),
|
|
93
|
-
emailEncodingKey: ts_types_1.ensure(ts_types_1.getString(results, exports.REQUIRED_FIELDS.emailEncodingKey)),
|
|
94
|
-
languageLocaleKey: ts_types_1.ensure(ts_types_1.getString(results, exports.REQUIRED_FIELDS.languageLocaleKey)),
|
|
95
|
-
localeSidKey: ts_types_1.ensure(ts_types_1.getString(results, exports.REQUIRED_FIELDS.localeSidKey)),
|
|
96
|
-
profileId: ts_types_1.ensure(ts_types_1.getString(results, exports.REQUIRED_FIELDS.profileId)),
|
|
97
|
-
lastName: ts_types_1.ensure(ts_types_1.getString(results, exports.REQUIRED_FIELDS.lastName)),
|
|
98
|
-
timeZoneSidKey: ts_types_1.ensure(ts_types_1.getString(results, exports.REQUIRED_FIELDS.timeZoneSidKey)),
|
|
91
|
+
alias: (0, ts_types_1.ensure)((0, ts_types_1.getString)(results, exports.REQUIRED_FIELDS.alias)),
|
|
92
|
+
email: (0, ts_types_1.ensure)((0, ts_types_1.getString)(results, exports.REQUIRED_FIELDS.email)),
|
|
93
|
+
emailEncodingKey: (0, ts_types_1.ensure)((0, ts_types_1.getString)(results, exports.REQUIRED_FIELDS.emailEncodingKey)),
|
|
94
|
+
languageLocaleKey: (0, ts_types_1.ensure)((0, ts_types_1.getString)(results, exports.REQUIRED_FIELDS.languageLocaleKey)),
|
|
95
|
+
localeSidKey: (0, ts_types_1.ensure)((0, ts_types_1.getString)(results, exports.REQUIRED_FIELDS.localeSidKey)),
|
|
96
|
+
profileId: (0, ts_types_1.ensure)((0, ts_types_1.getString)(results, exports.REQUIRED_FIELDS.profileId)),
|
|
97
|
+
lastName: (0, ts_types_1.ensure)((0, ts_types_1.getString)(results, exports.REQUIRED_FIELDS.lastName)),
|
|
98
|
+
timeZoneSidKey: (0, ts_types_1.ensure)((0, ts_types_1.getString)(results, exports.REQUIRED_FIELDS.timeZoneSidKey)),
|
|
99
99
|
};
|
|
100
100
|
return fields;
|
|
101
101
|
}
|
|
@@ -231,7 +231,7 @@ class User extends kit_1.AsyncCreatable {
|
|
|
231
231
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
232
232
|
// @ts-ignore TODO: expose `soap` on Connection however appropriate
|
|
233
233
|
const soap = userConnection.soap;
|
|
234
|
-
await soap.setPassword(ts_types_1.ensureString(info.getFields().userId), buffer.toString('utf8'));
|
|
234
|
+
await soap.setPassword((0, ts_types_1.ensureString)(info.getFields().userId), buffer.toString('utf8'));
|
|
235
235
|
this.logger.debug(`Set password for userId: ${info.getFields().userId}`);
|
|
236
236
|
resolve();
|
|
237
237
|
}
|
|
@@ -389,17 +389,17 @@ class User extends kit_1.AsyncCreatable {
|
|
|
389
389
|
body,
|
|
390
390
|
};
|
|
391
391
|
const response = await this.rawRequest(conn, info);
|
|
392
|
-
const responseBody = kit_1.parseJsonMap(ts_types_1.ensureString(response['body']));
|
|
393
|
-
const statusCode = ts_types_1.asNumber(response.statusCode);
|
|
392
|
+
const responseBody = (0, kit_1.parseJsonMap)((0, ts_types_1.ensureString)(response['body']));
|
|
393
|
+
const statusCode = (0, ts_types_1.asNumber)(response.statusCode);
|
|
394
394
|
this.logger.debug(`user create response.statusCode: ${response.statusCode}`);
|
|
395
395
|
if (!(statusCode === 201 || statusCode === 200)) {
|
|
396
396
|
let message = messages.getMessage('invalidHttpResponseCreatingUser', [statusCode]);
|
|
397
397
|
if (responseBody) {
|
|
398
|
-
const errors = ts_types_1.asJsonArray(responseBody.Errors);
|
|
398
|
+
const errors = (0, ts_types_1.asJsonArray)(responseBody.Errors);
|
|
399
399
|
if (errors && errors.length > 0) {
|
|
400
400
|
message = `${message} causes:${os_1.EOL}`;
|
|
401
401
|
errors.forEach((singleMessage) => {
|
|
402
|
-
if (!ts_types_1.isJsonMap(singleMessage))
|
|
402
|
+
if (!(0, ts_types_1.isJsonMap)(singleMessage))
|
|
403
403
|
return;
|
|
404
404
|
message = `${message}${os_1.EOL}${singleMessage.description}`;
|
|
405
405
|
});
|
|
@@ -408,11 +408,11 @@ class User extends kit_1.AsyncCreatable {
|
|
|
408
408
|
this.logger.debug(message);
|
|
409
409
|
throw new sfdxError_1.SfdxError(message, 'UserCreateHttpError');
|
|
410
410
|
}
|
|
411
|
-
fields.id = ts_types_1.ensureString(responseBody.id);
|
|
411
|
+
fields.id = (0, ts_types_1.ensureString)(responseBody.id);
|
|
412
412
|
await this.updateRequiredUserFields(fields);
|
|
413
413
|
const buffer = new secureBuffer_1.SecureBuffer();
|
|
414
|
-
const headers = ts_types_1.ensureJsonMap(response.headers);
|
|
415
|
-
const autoApproveUser = ts_types_1.ensureString(headers['auto-approve-user']);
|
|
414
|
+
const headers = (0, ts_types_1.ensureJsonMap)(response.headers);
|
|
415
|
+
const autoApproveUser = (0, ts_types_1.ensureString)(headers['auto-approve-user']);
|
|
416
416
|
buffer.consume(Buffer.from(autoApproveUser));
|
|
417
417
|
return {
|
|
418
418
|
buffer,
|
|
@@ -433,13 +433,13 @@ class User extends kit_1.AsyncCreatable {
|
|
|
433
433
|
* @param fields The fields for the user.
|
|
434
434
|
*/
|
|
435
435
|
async updateRequiredUserFields(fields) {
|
|
436
|
-
const leftOverRequiredFields = kit_1.omit(fields, [
|
|
436
|
+
const leftOverRequiredFields = (0, kit_1.omit)(fields, [
|
|
437
437
|
exports.REQUIRED_FIELDS.username,
|
|
438
438
|
exports.REQUIRED_FIELDS.email,
|
|
439
439
|
exports.REQUIRED_FIELDS.lastName,
|
|
440
440
|
exports.REQUIRED_FIELDS.profileId,
|
|
441
441
|
]);
|
|
442
|
-
const object = kit_1.mapKeys(leftOverRequiredFields, (value, key) => kit_1.upperFirst(key));
|
|
442
|
+
const object = (0, kit_1.mapKeys)(leftOverRequiredFields, (value, key) => (0, kit_1.upperFirst)(key));
|
|
443
443
|
await this.org.getConnection().sobject('User').update(object);
|
|
444
444
|
this.logger.debug(`Successfully Updated additional properties for user: ${fields.username}`);
|
|
445
445
|
}
|
package/lib/schema/printer.js
CHANGED
|
@@ -90,11 +90,11 @@ class SchemaPrinter {
|
|
|
90
90
|
add('');
|
|
91
91
|
}
|
|
92
92
|
Object.keys(this.schema.properties).forEach((key) => {
|
|
93
|
-
const properties = ts_types_1.asJsonMap(this.schema.properties);
|
|
93
|
+
const properties = (0, ts_types_1.asJsonMap)(this.schema.properties);
|
|
94
94
|
if (!properties) {
|
|
95
95
|
return;
|
|
96
96
|
}
|
|
97
|
-
this.parseProperty(key, ts_types_1.asJsonMap(properties[key]), startLevel);
|
|
97
|
+
this.parseProperty(key, (0, ts_types_1.asJsonMap)(properties[key]), startLevel);
|
|
98
98
|
add('');
|
|
99
99
|
});
|
|
100
100
|
}
|
|
@@ -144,15 +144,15 @@ class SchemaPrinter {
|
|
|
144
144
|
add(` ${property.renderArrayHeader()}`);
|
|
145
145
|
if (property.items && property.items.type === 'object' && property.items.properties) {
|
|
146
146
|
Object.keys(property.items.properties).forEach((key) => {
|
|
147
|
-
const items = ts_types_1.asJsonMap(property.items);
|
|
147
|
+
const items = (0, ts_types_1.asJsonMap)(property.items);
|
|
148
148
|
if (!items) {
|
|
149
149
|
return;
|
|
150
150
|
}
|
|
151
|
-
const properties = ts_types_1.asJsonMap(items.properties);
|
|
151
|
+
const properties = (0, ts_types_1.asJsonMap)(items.properties);
|
|
152
152
|
if (!properties) {
|
|
153
153
|
return;
|
|
154
154
|
}
|
|
155
|
-
this.parseProperty(key, ts_types_1.asJsonMap(properties[key]), level + 2);
|
|
155
|
+
this.parseProperty(key, (0, ts_types_1.asJsonMap)(properties[key]), level + 2);
|
|
156
156
|
});
|
|
157
157
|
}
|
|
158
158
|
}
|
|
@@ -176,16 +176,16 @@ class SchemaProperty {
|
|
|
176
176
|
// if they are defined here, they take precedence over referenced definition properties.
|
|
177
177
|
this.rawProperty = Object.assign({}, resolveRef(this.schema, this.rawProperty), rawProperty);
|
|
178
178
|
}
|
|
179
|
-
const oneOfs = ts_types_1.asJsonArray(this.rawProperty.oneOf);
|
|
179
|
+
const oneOfs = (0, ts_types_1.asJsonArray)(this.rawProperty.oneOf);
|
|
180
180
|
if (oneOfs && !this.rawProperty.type) {
|
|
181
181
|
this.rawProperty.type = oneOfs
|
|
182
182
|
.map((value) => {
|
|
183
|
-
return ts_types_1.isJsonMap(value) ? value.type || value.$ref : value;
|
|
183
|
+
return (0, ts_types_1.isJsonMap)(value) ? value.type || value.$ref : value;
|
|
184
184
|
})
|
|
185
185
|
.join('|');
|
|
186
186
|
}
|
|
187
187
|
// Handle items references
|
|
188
|
-
if (ts_types_1.isJsonMap(this.items) && this.items && this.items.$ref) {
|
|
188
|
+
if ((0, ts_types_1.isJsonMap)(this.items) && this.items && this.items.$ref) {
|
|
189
189
|
Object.assign(this.items, resolveRef(this.schema, this.items));
|
|
190
190
|
}
|
|
191
191
|
}
|
|
@@ -213,32 +213,32 @@ class SchemaProperty {
|
|
|
213
213
|
return `items(${prop.renderType()}${minItems}) - ${prop.renderTitle()}: ${prop.renderDescription()}`;
|
|
214
214
|
}
|
|
215
215
|
get title() {
|
|
216
|
-
return ts_types_1.asString(this.rawProperty.title);
|
|
216
|
+
return (0, ts_types_1.asString)(this.rawProperty.title);
|
|
217
217
|
}
|
|
218
218
|
get description() {
|
|
219
|
-
return ts_types_1.asString(this.rawProperty.description);
|
|
219
|
+
return (0, ts_types_1.asString)(this.rawProperty.description);
|
|
220
220
|
}
|
|
221
221
|
get type() {
|
|
222
|
-
return ts_types_1.asString(this.rawProperty.type);
|
|
222
|
+
return (0, ts_types_1.asString)(this.rawProperty.type);
|
|
223
223
|
}
|
|
224
224
|
get required() {
|
|
225
|
-
return ts_types_1.asJsonArray(this.rawProperty.required);
|
|
225
|
+
return (0, ts_types_1.asJsonArray)(this.rawProperty.required);
|
|
226
226
|
}
|
|
227
227
|
get properties() {
|
|
228
|
-
return ts_types_1.asJsonMap(this.rawProperty.properties);
|
|
228
|
+
return (0, ts_types_1.asJsonMap)(this.rawProperty.properties);
|
|
229
229
|
}
|
|
230
230
|
get items() {
|
|
231
|
-
return ts_types_1.asJsonMap(this.rawProperty.items);
|
|
231
|
+
return (0, ts_types_1.asJsonMap)(this.rawProperty.items);
|
|
232
232
|
}
|
|
233
233
|
get minItems() {
|
|
234
|
-
return ts_types_1.asNumber(this.rawProperty.minItems);
|
|
234
|
+
return (0, ts_types_1.asNumber)(this.rawProperty.minItems);
|
|
235
235
|
}
|
|
236
236
|
getProperty(key) {
|
|
237
237
|
const properties = this.getProperties();
|
|
238
|
-
return ts_types_1.asJsonMap(properties && properties[key]);
|
|
238
|
+
return (0, ts_types_1.asJsonMap)(properties && properties[key]);
|
|
239
239
|
}
|
|
240
240
|
getProperties() {
|
|
241
|
-
return ts_types_1.asJsonMap(this.rawProperty.properties);
|
|
241
|
+
return (0, ts_types_1.asJsonMap)(this.rawProperty.properties);
|
|
242
242
|
}
|
|
243
243
|
}
|
|
244
244
|
/**
|
|
@@ -254,7 +254,7 @@ function resolveRef(schema, property) {
|
|
|
254
254
|
}
|
|
255
255
|
return ref.split('/').reduce((prev, key) => {
|
|
256
256
|
const next = prev[key];
|
|
257
|
-
return key === '#' ? schema : ts_types_1.isJsonMap(next) ? next : {};
|
|
257
|
+
return key === '#' ? schema : (0, ts_types_1.isJsonMap)(next) ? next : {};
|
|
258
258
|
}, property);
|
|
259
259
|
}
|
|
260
260
|
//# sourceMappingURL=printer.js.map
|
package/lib/schema/validator.js
CHANGED
|
@@ -101,14 +101,14 @@ class SchemaValidator {
|
|
|
101
101
|
*/
|
|
102
102
|
loadExternalSchemas(schema) {
|
|
103
103
|
const externalSchemas = {};
|
|
104
|
-
const schemas = kit_1.getJsonValuesByName(schema, '$ref')
|
|
104
|
+
const schemas = (0, kit_1.getJsonValuesByName)(schema, '$ref')
|
|
105
105
|
// eslint-disable-next-line no-useless-escape
|
|
106
106
|
.map((ref) => ref && RegExp(/([\w\.]+)#/).exec(ref))
|
|
107
107
|
.map((match) => match && match[1])
|
|
108
108
|
.filter((uri) => !!uri)
|
|
109
109
|
.map((uri) => this.loadExternalSchema(uri));
|
|
110
110
|
schemas.forEach((externalSchema) => {
|
|
111
|
-
if (ts_types_1.isString(externalSchema.id)) {
|
|
111
|
+
if ((0, ts_types_1.isString)(externalSchema.id)) {
|
|
112
112
|
externalSchemas[externalSchema.id] = externalSchema;
|
|
113
113
|
}
|
|
114
114
|
else {
|
|
@@ -147,25 +147,25 @@ class SchemaValidator {
|
|
|
147
147
|
const property = RegExp(/^([a-zA-Z0-9\.]+)\.([a-zA-Z0-9]+)$/).exec(error.path);
|
|
148
148
|
const getPropValue = (prop) => {
|
|
149
149
|
const reducer = (obj, name) => {
|
|
150
|
-
if (!ts_types_1.isJsonMap(obj))
|
|
150
|
+
if (!(0, ts_types_1.isJsonMap)(obj))
|
|
151
151
|
return;
|
|
152
|
-
if (ts_types_1.isJsonMap(obj.properties))
|
|
152
|
+
if ((0, ts_types_1.isJsonMap)(obj.properties))
|
|
153
153
|
return obj.properties[name];
|
|
154
154
|
if (name === '0')
|
|
155
|
-
return ts_types_1.asJsonArray(obj.items);
|
|
155
|
+
return (0, ts_types_1.asJsonArray)(obj.items);
|
|
156
156
|
return obj[name] || obj[prop];
|
|
157
157
|
};
|
|
158
158
|
return error.path.split('.').reduce(reducer, schema);
|
|
159
159
|
};
|
|
160
160
|
const getEnumValues = () => {
|
|
161
|
-
const enumSchema = ts_types_1.asJsonMap(getPropValue('enum'));
|
|
162
|
-
return (enumSchema && ts_types_1.getJsonArray(enumSchema, 'enum', []).join(', ')) || '';
|
|
161
|
+
const enumSchema = (0, ts_types_1.asJsonMap)(getPropValue('enum'));
|
|
162
|
+
return (enumSchema && (0, ts_types_1.getJsonArray)(enumSchema, 'enum', []).join(', ')) || '';
|
|
163
163
|
};
|
|
164
164
|
switch (error.keyword) {
|
|
165
165
|
case 'additionalProperties':
|
|
166
166
|
// Missing Typing
|
|
167
167
|
// eslint-disable-next-line no-case-declarations
|
|
168
|
-
const additionalProperties = ts_types_1.get(error, 'additionalProperties');
|
|
168
|
+
const additionalProperties = (0, ts_types_1.get)(error, 'additionalProperties');
|
|
169
169
|
return `${error.path} should NOT have additional properties '${additionalProperties}'`;
|
|
170
170
|
case 'required':
|
|
171
171
|
if (property) {
|
package/lib/sfdxError.d.ts
CHANGED
|
@@ -50,7 +50,7 @@ export declare class SfdxError extends NamedError {
|
|
|
50
50
|
* @param err The error to convert.
|
|
51
51
|
*/
|
|
52
52
|
static wrap(err: Error | string): SfdxError;
|
|
53
|
-
get code(): string;
|
|
53
|
+
get code(): string | undefined | any;
|
|
54
54
|
set code(code: string);
|
|
55
55
|
/**
|
|
56
56
|
* Sets the context of the error. For convenience `this` object is returned.
|
package/lib/sfdxError.js
CHANGED
|
@@ -52,7 +52,7 @@ class SfdxError extends kit_1.NamedError {
|
|
|
52
52
|
* @param err The error to convert.
|
|
53
53
|
*/
|
|
54
54
|
static wrap(err) {
|
|
55
|
-
if (ts_types_1.isString(err)) {
|
|
55
|
+
if ((0, ts_types_1.isString)(err)) {
|
|
56
56
|
return new SfdxError(err);
|
|
57
57
|
}
|
|
58
58
|
if (err instanceof SfdxError) {
|
|
@@ -60,11 +60,12 @@ class SfdxError extends kit_1.NamedError {
|
|
|
60
60
|
}
|
|
61
61
|
const sfdxError = new SfdxError(err.message, err.name, undefined, err);
|
|
62
62
|
// If the original error has a code, use that instead of name.
|
|
63
|
-
if (ts_types_1.hasString(err, 'code')) {
|
|
63
|
+
if ((0, ts_types_1.hasString)(err, 'code')) {
|
|
64
64
|
sfdxError.code = err.code;
|
|
65
65
|
}
|
|
66
66
|
return sfdxError;
|
|
67
67
|
}
|
|
68
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
68
69
|
get code() {
|
|
69
70
|
return this._code || this.name;
|
|
70
71
|
}
|
package/lib/sfdxProject.js
CHANGED
|
@@ -110,12 +110,13 @@ class SfdxProjectJson extends configFile_1.ConfigFile {
|
|
|
110
110
|
await validator.validate(this.getContents());
|
|
111
111
|
}
|
|
112
112
|
catch (err) {
|
|
113
|
+
const error = err;
|
|
113
114
|
// Don't throw errors if the global isn't valid, but still warn the user.
|
|
114
115
|
if (kit_1.env.getBoolean('SFDX_PROJECT_JSON_VALIDATION', false) && !this.options.isGlobal) {
|
|
115
|
-
throw messages.createError('schemaValidationError', [this.getPath(),
|
|
116
|
+
throw messages.createError('schemaValidationError', [this.getPath(), error.message], [this.getPath()], error);
|
|
116
117
|
}
|
|
117
118
|
else {
|
|
118
|
-
this.logger.warn(messages.getMessage('schemaValidationError', [this.getPath(),
|
|
119
|
+
this.logger.warn(messages.getMessage('schemaValidationError', [this.getPath(), error.message]));
|
|
119
120
|
}
|
|
120
121
|
}
|
|
121
122
|
}
|
|
@@ -149,12 +150,13 @@ class SfdxProjectJson extends configFile_1.ConfigFile {
|
|
|
149
150
|
validator.validateSync(this.getContents());
|
|
150
151
|
}
|
|
151
152
|
catch (err) {
|
|
153
|
+
const error = err;
|
|
152
154
|
// Don't throw errors if the global isn't valid, but still warn the user.
|
|
153
155
|
if (kit_1.env.getBoolean('SFDX_PROJECT_JSON_VALIDATION', false) && !this.options.isGlobal) {
|
|
154
|
-
throw messages.createError('schemaValidationError', [this.getPath(),
|
|
156
|
+
throw messages.createError('schemaValidationError', [this.getPath(), error.message], [this.getPath()], error);
|
|
155
157
|
}
|
|
156
158
|
else {
|
|
157
|
-
this.logger.warn(messages.getMessage('schemaValidationError', [this.getPath(),
|
|
159
|
+
this.logger.warn(messages.getMessage('schemaValidationError', [this.getPath(), error.message]));
|
|
158
160
|
}
|
|
159
161
|
}
|
|
160
162
|
}
|
|
@@ -169,16 +171,16 @@ class SfdxProjectJson extends configFile_1.ConfigFile {
|
|
|
169
171
|
// This has to be done on the fly so it won't be written back to the file
|
|
170
172
|
// This is a fast operation so no need to cache it so it stays immutable.
|
|
171
173
|
const packageDirs = (contents.packageDirectories || []).map((packageDir) => {
|
|
172
|
-
if (path_1.isAbsolute(packageDir.path)) {
|
|
174
|
+
if ((0, path_1.isAbsolute)(packageDir.path)) {
|
|
173
175
|
throw messages.createError('invalidPackageDirectory', [packageDir.path]);
|
|
174
176
|
}
|
|
175
177
|
const regex = path_1.sep === '/' ? /\\/g : /\//g;
|
|
176
178
|
// Change packageDir paths to have path separators that match the OS
|
|
177
179
|
const path = packageDir.path.replace(regex, path_1.sep);
|
|
178
180
|
// Normalize and remove any ending path separators
|
|
179
|
-
const name = path_1.normalize(path).replace(new RegExp(`\\${path_1.sep}$`), '');
|
|
181
|
+
const name = (0, path_1.normalize)(path).replace(new RegExp(`\\${path_1.sep}$`), '');
|
|
180
182
|
// Always end in a path sep for standardization on folder paths
|
|
181
|
-
const fullPath = `${path_1.dirname(this.getPath())}${path_1.sep}${name}${path_1.sep}`;
|
|
183
|
+
const fullPath = `${(0, path_1.dirname)(this.getPath())}${path_1.sep}${name}${path_1.sep}`;
|
|
182
184
|
if (!this.doesPackageExist(fullPath)) {
|
|
183
185
|
throw messages.createError('missingPackageDirectory', [packageDir.path]);
|
|
184
186
|
}
|
|
@@ -290,7 +292,7 @@ class SfdxProject {
|
|
|
290
292
|
const project = new SfdxProject(path);
|
|
291
293
|
SfdxProject.instances.set(path, project);
|
|
292
294
|
}
|
|
293
|
-
return ts_types_1.ensure(SfdxProject.instances.get(path));
|
|
295
|
+
return (0, ts_types_1.ensure)(SfdxProject.instances.get(path));
|
|
294
296
|
}
|
|
295
297
|
/**
|
|
296
298
|
* Get a Project from a given path or from the working directory.
|
|
@@ -306,7 +308,7 @@ class SfdxProject {
|
|
|
306
308
|
const project = new SfdxProject(path);
|
|
307
309
|
SfdxProject.instances.set(path, project);
|
|
308
310
|
}
|
|
309
|
-
return ts_types_1.ensure(SfdxProject.instances.get(path));
|
|
311
|
+
return (0, ts_types_1.ensure)(SfdxProject.instances.get(path));
|
|
310
312
|
}
|
|
311
313
|
/**
|
|
312
314
|
* Performs an upward directory search for an sfdx project file. Returns the absolute path to the project.
|
|
@@ -320,7 +322,7 @@ class SfdxProject {
|
|
|
320
322
|
* **See** [process.cwd()](https://nodejs.org/api/process.html#process_process_cwd)
|
|
321
323
|
*/
|
|
322
324
|
static async resolveProjectPath(dir) {
|
|
323
|
-
return internal_1.resolveProjectPath(dir);
|
|
325
|
+
return (0, internal_1.resolveProjectPath)(dir);
|
|
324
326
|
}
|
|
325
327
|
/**
|
|
326
328
|
* Performs a synchronous upward directory search for an sfdx project file. Returns the absolute path to the project.
|
|
@@ -334,7 +336,7 @@ class SfdxProject {
|
|
|
334
336
|
* **See** [process.cwd()](https://nodejs.org/api/process.html#process_process_cwd)
|
|
335
337
|
*/
|
|
336
338
|
static resolveProjectPathSync(dir) {
|
|
337
|
-
return internal_1.resolveProjectPathSync(dir);
|
|
339
|
+
return (0, internal_1.resolveProjectPathSync)(dir);
|
|
338
340
|
}
|
|
339
341
|
/**
|
|
340
342
|
* Returns the project path.
|
|
@@ -434,7 +436,7 @@ class SfdxProject {
|
|
|
434
436
|
*/
|
|
435
437
|
getPackageFromPath(path) {
|
|
436
438
|
const packageDirs = this.getPackageDirectories();
|
|
437
|
-
const match = packageDirs.find((packageDir) => path_1.basename(path) === packageDir.name || path.includes(packageDir.fullPath));
|
|
439
|
+
const match = packageDirs.find((packageDir) => (0, path_1.basename)(path) === packageDir.name || path.includes(packageDir.fullPath));
|
|
438
440
|
return match;
|
|
439
441
|
}
|
|
440
442
|
/**
|
|
@@ -530,7 +532,7 @@ class SfdxProject {
|
|
|
530
532
|
configAggregator_1.ConfigAggregator.create(),
|
|
531
533
|
]);
|
|
532
534
|
await Promise.all([global.read(), local.read()]);
|
|
533
|
-
this.projectConfig = kit_1.defaults(local.toObject(), global.toObject());
|
|
535
|
+
this.projectConfig = (0, kit_1.defaults)(local.toObject(), global.toObject());
|
|
534
536
|
// Add fields in sfdx-config.json
|
|
535
537
|
Object.assign(this.projectConfig, configAggregator.getConfig());
|
|
536
538
|
// we don't have a login url yet, so use instanceUrl from config or default
|
|
@@ -79,7 +79,7 @@ class MyDomainResolver extends kit_1.AsyncOptionalCreatable {
|
|
|
79
79
|
payload: '127.0.0.1',
|
|
80
80
|
};
|
|
81
81
|
}
|
|
82
|
-
dnsResult = await util_1.promisify(dns_1.lookup)(host);
|
|
82
|
+
dnsResult = await (0, util_1.promisify)(dns_1.lookup)(host);
|
|
83
83
|
self.logger.debug(`Successfully resolved host: ${host} result: ${JSON.stringify(dnsResult)}`);
|
|
84
84
|
return {
|
|
85
85
|
completed: true,
|
|
@@ -100,12 +100,12 @@ class MyDomainResolver extends kit_1.AsyncOptionalCreatable {
|
|
|
100
100
|
timeoutErrorName: 'MyDomainResolverTimeoutError',
|
|
101
101
|
};
|
|
102
102
|
const client = await pollingClient_1.PollingClient.create(pollingOptions);
|
|
103
|
-
return ts_types_1.ensureString(await client.subscribe());
|
|
103
|
+
return (0, ts_types_1.ensureString)(await client.subscribe());
|
|
104
104
|
}
|
|
105
105
|
async getCnames() {
|
|
106
106
|
try {
|
|
107
107
|
await this.resolve();
|
|
108
|
-
return await util_1.promisify(dns_1.resolveCname)(this.options.url.host);
|
|
108
|
+
return await (0, util_1.promisify)(dns_1.resolveCname)(this.options.url.host);
|
|
109
109
|
}
|
|
110
110
|
catch (e) {
|
|
111
111
|
this.logger.debug(`An error occurred trying to resolve: ${this.options.url.host}`);
|
|
@@ -39,7 +39,7 @@ class PollingClient extends kit_1.AsyncOptionalCreatable {
|
|
|
39
39
|
*/
|
|
40
40
|
constructor(options) {
|
|
41
41
|
super(options);
|
|
42
|
-
this.options = ts_types_1.ensure(options);
|
|
42
|
+
this.options = (0, ts_types_1.ensure)(options);
|
|
43
43
|
}
|
|
44
44
|
/**
|
|
45
45
|
* Asynchronous initializer.
|
|
@@ -69,7 +69,7 @@ class PollingClient extends kit_1.AsyncOptionalCreatable {
|
|
|
69
69
|
}
|
|
70
70
|
throw new Error('Operation did not complete. Retrying...'); // triggers a retry
|
|
71
71
|
};
|
|
72
|
-
const finalResult = ts_retry_promise_1.retryDecorator(doPoll, {
|
|
72
|
+
const finalResult = (0, ts_retry_promise_1.retryDecorator)(doPoll, {
|
|
73
73
|
timeout: this.options.timeout.milliseconds,
|
|
74
74
|
delay: this.options.frequency.milliseconds,
|
|
75
75
|
retries: 'INFINITELY',
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { AsyncOptionalCreatable, Duration, Env } from '@salesforce/kit/lib';
|
|
2
2
|
import { AnyJson } from '@salesforce/ts-types/lib';
|
|
3
|
-
import type { Client as CometClient, StreamProcessor } from 'sfdx-faye';
|
|
4
3
|
import { Org } from '../org/org';
|
|
5
|
-
|
|
4
|
+
import { CometClient, CometSubscription, Message, StatusResult, StreamingExtension, StreamProcessor } from './types';
|
|
5
|
+
export { CometClient, CometSubscription, Message, StatusResult, StreamingExtension, StreamProcessor };
|
|
6
6
|
/**
|
|
7
7
|
* Inner streaming client interface. This implements the Cometd behavior.
|
|
8
8
|
* Also allows for mocking the functional behavior.
|
|
@@ -187,7 +187,6 @@ export declare namespace StreamingClient {
|
|
|
187
187
|
handshakeTimeout: Duration;
|
|
188
188
|
channel: string;
|
|
189
189
|
streamingImpl: StreamingClientIfc;
|
|
190
|
-
private envDep;
|
|
191
190
|
/**
|
|
192
191
|
* Constructor for DefaultStreamingOptions
|
|
193
192
|
*
|
|
@@ -11,12 +11,12 @@ exports.StreamingClient = exports.CometClient = void 0;
|
|
|
11
11
|
const url_1 = require("url");
|
|
12
12
|
const lib_1 = require("@salesforce/kit/lib");
|
|
13
13
|
const lib_2 = require("@salesforce/ts-types/lib");
|
|
14
|
-
const Faye = require("
|
|
14
|
+
const Faye = require("faye");
|
|
15
15
|
const logger_1 = require("../logger");
|
|
16
16
|
const sfdxError_1 = require("../sfdxError");
|
|
17
17
|
const messages_1 = require("../messages");
|
|
18
|
-
|
|
19
|
-
Object.defineProperty(exports, "CometClient", { enumerable: true, get: function () { return
|
|
18
|
+
const types_1 = require("./types");
|
|
19
|
+
Object.defineProperty(exports, "CometClient", { enumerable: true, get: function () { return types_1.CometClient; } });
|
|
20
20
|
messages_1.Messages.importMessagesDirectory(__dirname);
|
|
21
21
|
const messages = messages_1.Messages.load('@salesforce/core', 'streaming', [
|
|
22
22
|
'waitParamValidValueError',
|
|
@@ -108,8 +108,8 @@ class StreamingClient extends lib_1.AsyncOptionalCreatable {
|
|
|
108
108
|
*/
|
|
109
109
|
constructor(options) {
|
|
110
110
|
super(options);
|
|
111
|
-
this.options = lib_2.ensure(options);
|
|
112
|
-
const instanceUrl = lib_2.ensure(this.options.org.getConnection().getAuthInfoFields().instanceUrl);
|
|
111
|
+
this.options = (0, lib_2.ensure)(options);
|
|
112
|
+
const instanceUrl = (0, lib_2.ensure)(this.options.org.getConnection().getAuthInfoFields().instanceUrl);
|
|
113
113
|
/**
|
|
114
114
|
* The salesforce network infrastructure issues a cookie called sfdx-stream if it sees /cometd in the url.
|
|
115
115
|
* Without this cookie request response streams will experience intermittent client session failures.
|
|
@@ -126,7 +126,7 @@ class StreamingClient extends lib_1.AsyncOptionalCreatable {
|
|
|
126
126
|
* Enable SFDX_ENABLE_FAYE_REQUEST_RESPONSE_LOGGING to debug potential session problems and to verify cookie
|
|
127
127
|
* exchanges.
|
|
128
128
|
*/
|
|
129
|
-
this.targetUrl = url_1.resolve(instanceUrl, `cometd/${this.options.apiVersion}`);
|
|
129
|
+
this.targetUrl = (0, url_1.resolve)(instanceUrl, `cometd/${this.options.apiVersion}`);
|
|
130
130
|
this.cometClient = this.options.streamingImpl.getCometClient(this.targetUrl);
|
|
131
131
|
this.options.streamingImpl.setLogger(this.log.bind(this));
|
|
132
132
|
this.cometClient.on('transport:up', () => this.log('Transport up event received'));
|
|
@@ -172,7 +172,7 @@ class StreamingClient extends lib_1.AsyncOptionalCreatable {
|
|
|
172
172
|
const replayFromMap = {};
|
|
173
173
|
replayFromMap[this.options.channel] = replayId;
|
|
174
174
|
// add "ext : { "replay" : { CHANNEL : REPLAY_VALUE }}" to subscribe message
|
|
175
|
-
lib_1.set(message, 'ext.replay', replayFromMap);
|
|
175
|
+
(0, lib_1.set)(message, 'ext.replay', replayFromMap);
|
|
176
176
|
}
|
|
177
177
|
callback(message);
|
|
178
178
|
},
|
|
@@ -273,7 +273,7 @@ class StreamingClient extends lib_1.AsyncOptionalCreatable {
|
|
|
273
273
|
if (message &&
|
|
274
274
|
message.channel === '/meta/handshake' &&
|
|
275
275
|
message.error &&
|
|
276
|
-
lib_2.ensureString(message.error).includes('400::API version in the URI is mandatory')) {
|
|
276
|
+
(0, lib_2.ensureString)(message.error).includes('400::API version in the URI is mandatory')) {
|
|
277
277
|
throw messages.createError('handshakeApiVersionError', [this.options.apiVersion]);
|
|
278
278
|
}
|
|
279
279
|
cb(message);
|
|
@@ -337,6 +337,10 @@ exports.StreamingClient = StreamingClient;
|
|
|
337
337
|
* @see {@link StatusResult}
|
|
338
338
|
*/
|
|
339
339
|
constructor(org, channel, streamProcessor, envDep = lib_1.env) {
|
|
340
|
+
if (envDep) {
|
|
341
|
+
const logger = logger_1.Logger.childFromRoot('StreamingClient');
|
|
342
|
+
logger.warn('envDep is deprecated');
|
|
343
|
+
}
|
|
340
344
|
if (!streamProcessor) {
|
|
341
345
|
throw new sfdxError_1.SfdxError('Missing stream processor', 'MissingArg');
|
|
342
346
|
}
|
|
@@ -346,7 +350,6 @@ exports.StreamingClient = StreamingClient;
|
|
|
346
350
|
if (!channel) {
|
|
347
351
|
throw new sfdxError_1.SfdxError('Missing streaming channel', 'MissingArg');
|
|
348
352
|
}
|
|
349
|
-
this.envDep = envDep;
|
|
350
353
|
this.org = org;
|
|
351
354
|
this.apiVersion = org.getConnection().getApiVersion();
|
|
352
355
|
if (channel.startsWith('/system')) {
|
|
@@ -361,24 +364,15 @@ exports.StreamingClient = StreamingClient;
|
|
|
361
364
|
this.handshakeTimeout = StreamingClient.DefaultOptions.DEFAULT_HANDSHAKE_TIMEOUT;
|
|
362
365
|
this.streamingImpl = {
|
|
363
366
|
getCometClient: (url) => {
|
|
364
|
-
|
|
365
|
-
return new Faye.Client(url
|
|
366
|
-
// This parameter ensures all cookies regardless of path are included in subsequent requests. Otherwise
|
|
367
|
-
// only cookies with the path "/" and "/cometd" are known to be included.
|
|
368
|
-
// if SFDX_ENABLE_FAYE_COOKIES_ALLOW_ALL_PATHS is *not* set the default to true.
|
|
369
|
-
cookiesAllowAllPaths: x === undefined
|
|
370
|
-
? true
|
|
371
|
-
: this.envDep.getBoolean(StreamingClient.DefaultOptions.SFDX_ENABLE_FAYE_COOKIES_ALLOW_ALL_PATHS),
|
|
372
|
-
// WARNING - The allows request/response exchanges to be written to the log instance which includes
|
|
373
|
-
// header and cookie information.
|
|
374
|
-
enableRequestResponseLogging: this.envDep.getBoolean(StreamingClient.DefaultOptions.SFDX_ENABLE_FAYE_REQUEST_RESPONSE_LOGGING),
|
|
375
|
-
});
|
|
367
|
+
// @ts-ignore
|
|
368
|
+
return new Faye.Client(url);
|
|
376
369
|
},
|
|
377
370
|
setLogger: (logLine) => {
|
|
378
371
|
// @ts-ignore
|
|
379
372
|
Faye.logger = {};
|
|
380
373
|
['info', 'error', 'fatal', 'warn', 'debug'].forEach((element) => {
|
|
381
|
-
|
|
374
|
+
// @ts-ignore
|
|
375
|
+
(0, lib_1.set)(Faye.logger, element, logLine);
|
|
382
376
|
});
|
|
383
377
|
},
|
|
384
378
|
};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { EventEmitter } from 'events';
|
|
3
|
+
import { AnyFunction, AnyJson, JsonMap } from '@salesforce/ts-types';
|
|
4
|
+
export declare type Message = JsonMap;
|
|
5
|
+
export declare type Callback<T = unknown> = (...args: any[]) => T;
|
|
6
|
+
export interface StatusResult {
|
|
7
|
+
/**
|
|
8
|
+
* If the result of the streaming or polling client is expected to return a result
|
|
9
|
+
*/
|
|
10
|
+
payload?: AnyJson;
|
|
11
|
+
/**
|
|
12
|
+
* Indicates to the streaming or polling client that the subscriber has what its needs. If `true` the client will end
|
|
13
|
+
* the messaging exchanges with the endpoint.
|
|
14
|
+
*/
|
|
15
|
+
completed: boolean;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The subscription object returned from the cometd subscribe object.
|
|
19
|
+
*/
|
|
20
|
+
export interface CometSubscription {
|
|
21
|
+
callback(callback: () => void): void;
|
|
22
|
+
errback(callback: (error: Error) => void): void;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Types for defining extensions.
|
|
26
|
+
*/
|
|
27
|
+
export interface StreamingExtension {
|
|
28
|
+
/**
|
|
29
|
+
* Extension for outgoing message.
|
|
30
|
+
*
|
|
31
|
+
* @param message The message.
|
|
32
|
+
* @param callback The callback to invoke after the message is processed.
|
|
33
|
+
*/
|
|
34
|
+
outgoing?: (message: JsonMap, callback: AnyFunction) => void;
|
|
35
|
+
/**
|
|
36
|
+
* Extension for the incoming message.
|
|
37
|
+
*
|
|
38
|
+
* @param message The message.
|
|
39
|
+
* @param callback The callback to invoke after the message is processed.
|
|
40
|
+
*/
|
|
41
|
+
incoming?: (message: JsonMap, callback: AnyFunction) => void;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Function type for processing messages
|
|
45
|
+
*/
|
|
46
|
+
export declare type StreamProcessor = (message: JsonMap) => StatusResult;
|
|
47
|
+
/**
|
|
48
|
+
* Comet client interface. The is to allow for mocking the inner streaming Cometd implementation.
|
|
49
|
+
* The Faye implementation is used by default but it could be used to adapt another Cometd impl.
|
|
50
|
+
*/
|
|
51
|
+
export declare abstract class CometClient extends EventEmitter {
|
|
52
|
+
/**
|
|
53
|
+
* Disable polling features.
|
|
54
|
+
*
|
|
55
|
+
* @param label Polling feature label.
|
|
56
|
+
*/
|
|
57
|
+
abstract disable(label: string): void;
|
|
58
|
+
/**
|
|
59
|
+
* Add a custom extension to the underlying client.
|
|
60
|
+
*
|
|
61
|
+
* @param extension The json function for the extension.
|
|
62
|
+
*/
|
|
63
|
+
abstract addExtension(extension: StreamingExtension): void;
|
|
64
|
+
/**
|
|
65
|
+
* Sets an http header name/value.
|
|
66
|
+
*
|
|
67
|
+
* @param name The header name.
|
|
68
|
+
* @param value The header value.
|
|
69
|
+
*/
|
|
70
|
+
abstract setHeader(name: string, value: string): void;
|
|
71
|
+
/**
|
|
72
|
+
* handshake with the streaming channel
|
|
73
|
+
*
|
|
74
|
+
* @param callback Callback for the handshake when it successfully completes. The handshake should throw
|
|
75
|
+
* errors when errors are encountered.
|
|
76
|
+
*/
|
|
77
|
+
abstract handshake(callback: () => void): void;
|
|
78
|
+
/**
|
|
79
|
+
* Subscribes to Comet topics. Subscribe should perform a handshake if one hasn't been performed yet.
|
|
80
|
+
*
|
|
81
|
+
* @param channel The topic to subscribe to.
|
|
82
|
+
* @param callback The callback to execute once a message has been received.
|
|
83
|
+
*/
|
|
84
|
+
abstract subscribe(channel: string, callback: (message: JsonMap) => void): CometSubscription;
|
|
85
|
+
/**
|
|
86
|
+
* Method to call to disconnect the client from the server.
|
|
87
|
+
*/
|
|
88
|
+
abstract disconnect(): void;
|
|
89
|
+
}
|