Skip to content

Commit

Permalink
chore: rebase to the updated main branch
Browse files Browse the repository at this point in the history
  • Loading branch information
mingxuanzhangsfdx committed Jan 5, 2024
1 parent 244733d commit dbc10fc
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 24 deletions.
16 changes: 16 additions & 0 deletions dist/exported.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2269,6 +2269,9 @@ declare module '@salesforce/core/messages' {
* // Create loader functions for all files in the messages directory
* Messages.importMessagesDirectory(__dirname);
*
* // or, for ESM code
* Messages.importMessagesDirectoryFromMetaUrl(import.meta.url)
*
* // Now you can use the messages from anywhere in your code or file.
* // If using importMessageDirectory, the bundle name is the file name.
* const messages: Messages = Messages.loadMessages(packageName, bundleName);
Expand Down Expand Up @@ -2337,6 +2340,19 @@ declare module '@salesforce/core/messages' {
* @param filePath The path of the file.
*/
static importMessageFile(packageName: string, filePath: string): void;
/**
* Support ESM plugins who can't use __dirname
*
* @param metaUrl pass in `import.meta.url`
* @param truncateToProjectPath Will look for the messages directory in the project root (where the package.json file is located).
* i.e., the module is typescript and the messages folder is in the top level of the module directory.
* @param packageName The npm package name. Figured out from the root directory's package.json.
*/
static importMessagesDirectoryFromMetaUrl(
metaUrl: string,
truncateToProjectPath?: boolean,
packageName?: string
): void;
/**
* Import all json and js files in a messages directory. Use the file name as the bundle key when
* {@link Messages.loadMessages} is called. By default, we're assuming the moduleDirectoryPart is a
Expand Down
59 changes: 35 additions & 24 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -199280,6 +199280,7 @@ var fs = __toESM(require('node:fs'));
var os = __toESM(require('node:os'));
var path = __toESM(require('node:path'));
var util = __toESM(require('node:util'));
var import_node_url = require('node:url');
var import_ts_types2 = __toESM(require_lib());
var import_kit2 = __toESM(require_lib2());

Expand Down Expand Up @@ -199530,6 +199531,21 @@ var Messages = class _Messages {
this.setLoaderFunction(packageName, bundleName, _Messages.generateFileLoaderFunction(bundleName, filePath));
}
}
/**
* Support ESM plugins who can't use __dirname
*
* @param metaUrl pass in `import.meta.url`
* @param truncateToProjectPath Will look for the messages directory in the project root (where the package.json file is located).
* i.e., the module is typescript and the messages folder is in the top level of the module directory.
* @param packageName The npm package name. Figured out from the root directory's package.json.
*/
static importMessagesDirectoryFromMetaUrl(metaUrl, truncateToProjectPath = true, packageName) {
return _Messages.importMessagesDirectory(
path.dirname((0, import_node_url.fileURLToPath)(metaUrl)),
truncateToProjectPath,
packageName
);
}
/**
* Import all json and js files in a messages directory. Use the file name as the bundle key when
* {@link Messages.loadMessages} is called. By default, we're assuming the moduleDirectoryPart is a
Expand Down Expand Up @@ -202001,7 +202017,7 @@ var import_kit10 = __toESM(require_lib2());
var import_semver = __toESM(require_semver2());

// package.json
var version = '6.3.0';
var version = '6.3.1-bundle-dev.0';

// src/lifecycleEvents.ts
var Lifecycle = class _Lifecycle {
Expand Down Expand Up @@ -203214,13 +203230,13 @@ var import_kit17 = __toESM(require_lib2());
var import_ts_types16 = __toESM(require_lib());

// src/util/sfdcUrl.ts
var import_node_url2 = require('node:url');
var import_node_url3 = require('node:url');
var import_kit16 = __toESM(require_lib2());
var import_ts_types14 = __toESM(require_lib());

// src/status/myDomainResolver.ts
var import_node_dns = require('node:dns');
var import_node_url = require('node:url');
var import_node_url2 = require('node:url');
var import_node_util = require('node:util');
var import_ts_types13 = __toESM(require_lib());
var import_kit15 = __toESM(require_lib2());
Expand Down Expand Up @@ -203323,7 +203339,7 @@ var MyDomainResolver = class _MyDomainResolver extends import_kit15.AsyncOptiona
this.options = options ?? { url: _MyDomainResolver.DEFAULT_DOMAIN };
}
static {
this.DEFAULT_DOMAIN = new import_node_url.URL('https://login.salesforce.com');
this.DEFAULT_DOMAIN = new import_node_url2.URL('https://login.salesforce.com');
}
getTimeout() {
return this.options.timeout ?? import_kit15.Duration.seconds(DNS_TIMEOUT);
Expand Down Expand Up @@ -203419,14 +203435,14 @@ function getLoginAudienceCombos(audienceUrl, loginUrl) {
)
);
const reduced = filtered.reduce((acc, [login, audience]) => {
const l = new import_node_url2.URL(login);
const a = new import_node_url2.URL(audience);
const l = new import_node_url3.URL(login);
const a = new import_node_url3.URL(audience);
acc.set(`${l.origin}:${a.origin}`, [login, audience]);
return acc;
}, /* @__PURE__ */ new Map());
return [...reduced.values()];
}
var SfdcUrl = class _SfdcUrl extends import_node_url2.URL {
var SfdcUrl = class _SfdcUrl extends import_node_url3.URL {
constructor(input, base) {
super(input.toString(), base);
if (this.protocol !== 'https:' && !_SfdcUrl.cache.has(this.origin)) {
Expand All @@ -203448,7 +203464,7 @@ var SfdcUrl = class _SfdcUrl extends import_node_url2.URL {
}
static isValidUrl(input) {
try {
new import_node_url2.URL(input.toString());
new import_node_url3.URL(input.toString());
return true;
} catch {
return false;
Expand Down Expand Up @@ -203555,7 +203571,7 @@ var SfdcUrl = class _SfdcUrl extends import_node_url2.URL {
return true;
}
const resolver = await MyDomainResolver.create({
url: new import_node_url2.URL(this.toLightningDomain()),
url: new import_node_url3.URL(this.toLightningDomain()),
timeout,
frequency: new import_kit16.Duration(1, import_kit16.Duration.Unit.SECONDS),
});
Expand All @@ -203573,7 +203589,7 @@ var SfdcUrl = class _SfdcUrl extends import_node_url2.URL {
const quantity = (0, import_ts_types14.ensureNumber)(new import_kit16.Env().getNumber('SFDX_DOMAIN_RETRY', 240));
const timeout = new import_kit16.Duration(quantity, import_kit16.Duration.Unit.SECONDS);
const resolver = await MyDomainResolver.create({
url: new import_node_url2.URL(this.origin),
url: new import_node_url3.URL(this.origin),
timeout,
frequency: new import_kit16.Duration(1, import_kit16.Duration.Unit.SECONDS),
});
Expand Down Expand Up @@ -204413,7 +204429,7 @@ var ConfigAggregator = class _ConfigAggregator extends import_kit18.AsyncOptiona
})(ConfigAggregator || (ConfigAggregator = {}));

// src/org/connection.ts
var import_node_url3 = require('node:url');
var import_node_url4 = require('node:url');
var import_kit19 = __toESM(require_lib2());
var import_ts_types18 = __toESM(require_lib());
var import_jsforce = __toESM(require_jsforce2());
Expand Down Expand Up @@ -204587,7 +204603,7 @@ var Connection = class extends import_jsforce.Connection {
throw messages9.createError('noInstanceUrlError');
}
const resolver = await MyDomainResolver.create({
url: new import_node_url3.URL(this.options.connectionOptions.instanceUrl),
url: new import_node_url4.URL(this.options.connectionOptions.instanceUrl),
});
try {
await resolver.resolve();
Expand Down Expand Up @@ -204676,7 +204692,7 @@ var Connection = class extends import_jsforce.Connection {
void Lifecycle.getInstance().emitWarning(
`The query result is missing ${
query.totalSize - query.records.length
} records due to a ${maxFetch} record limit. Increase the number of records returned by setting the config value "maxQueryLimit" or the environment variable "SFDX_MAX_QUERY_LIMIT" to ${
} records due to a ${maxFetch} record limit. Increase the number of records returned by setting the config value "maxQueryLimit" or the environment variable "SF_ORG_MAX_QUERY_LIMIT" to ${
query.totalSize
} or greater than ${maxFetch}.`
);
Expand Down Expand Up @@ -204793,7 +204809,7 @@ var OrgUsersConfig = class extends ConfigFile {
// src/webOAuthServer.ts
var http = __toESM(require('node:http'));
var import_node_querystring = require('node:querystring');
var import_node_url4 = require('node:url');
var import_node_url5 = require('node:url');
var import_node_net = require('node:net');
var import_node_events = require('node:events');
var import_jsforce2 = __toESM(require_jsforce2());
Expand Down Expand Up @@ -205632,7 +205648,7 @@ var WebOAuthServer = class _WebOAuthServer extends import_kit23.AsyncCreatable {
this.logger.debug('Starting web auth flow');
this.webServer.server.on('request', async (request, response) => {
if (request.url) {
const url = (0, import_node_url4.parse)(request.url);
const url = (0, import_node_url5.parse)(request.url);
this.logger.debug(`processing request for uri: ${url.pathname}`);
if (request.method === 'GET') {
if (url.pathname?.startsWith('/OauthRedirect') && url.query) {
Expand Down Expand Up @@ -205685,12 +205701,7 @@ var WebOAuthServer = class _WebOAuthServer extends import_kit23.AsyncCreatable {
parseAuthCodeFromRequest(response, request) {
if (!this.validateState(request)) {
const error = new SfError('urlStateMismatch');
this.webServer.sendError(
400,
`${error.message}
`,
response
);
this.webServer.sendError(400, error.message, response);
this.closeRequest(request);
this.logger.warn('urlStateMismatchAttempt detected.');
if (!(0, import_ts_types21.get)(this.webServer.server, 'urlStateMismatchAttempt')) {
Expand Down Expand Up @@ -205729,7 +205740,7 @@ var WebOAuthServer = class _WebOAuthServer extends import_kit23.AsyncCreatable {
*/
validateState(request) {
const state = request.query.state;
const query = (0, import_node_url4.parse)(this.authUrl, true).query;
const query = (0, import_node_url5.parse)(this.authUrl, true).query;
return !!(state && state === query.state);
}
};
Expand Down Expand Up @@ -209500,7 +209511,7 @@ async function getJwtAudienceUrl(options) {
}

// src/status/streamingClient.ts
var import_node_url5 = require('node:url');
var import_node_url6 = require('node:url');
var import_lib = __toESM(require_lib2());
var import_lib2 = __toESM(require_lib());
var import_faye = __toESM(require_faye_node());
Expand Down Expand Up @@ -209529,7 +209540,7 @@ var StreamingClient = class _StreamingClient extends import_lib.AsyncOptionalCre
super(options);
this.options = (0, import_lib2.ensure)(options);
const instanceUrl = (0, import_lib2.ensure)(this.options.org.getConnection().getAuthInfoFields().instanceUrl);
this.targetUrl = (0, import_node_url5.resolve)(instanceUrl, `cometd/${this.options.apiVersion}`);
this.targetUrl = (0, import_node_url6.resolve)(instanceUrl, `cometd/${this.options.apiVersion}`);
this.cometClient = this.options.streamingImpl.getCometClient(this.targetUrl);
this.options.streamingImpl.setLogger(this.log.bind(this));
this.cometClient.on('transport:up', () => this.log('Transport up event received'));
Expand Down

0 comments on commit dbc10fc

Please sign in to comment.