Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions configs/tsconfig-mongosh/tsconfig.common.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"noUnusedLocals": false,
"noUnusedParameters": false,
"noImplicitReturns": true,
"erasableSyntaxOnly": true,

"declaration": true,
"removeComments": true,
Expand Down
10 changes: 4 additions & 6 deletions packages/async-rewriter2/src/error-codes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* @mongoshErrors
*/
enum AsyncRewriterErrors {
export const AsyncRewriterErrors = {
/**
* Signals the use of a Mongosh API call in a place where it is not supported.
* This occurs inside of constructors and (non-async) generator functions.
Expand All @@ -23,7 +23,7 @@ enum AsyncRewriterErrors {
*
* **Solution: Do not use calls directly in such functions. If necessary, place these calls in an inner 'async' function.**
*/
SyntheticPromiseInAlwaysSyncContext = 'ASYNC-10012',
SyntheticPromiseInAlwaysSyncContext: 'ASYNC-10012',
/**
* Signals the iteration of a Mongosh API object in a place where it is not supported.
* This occurs inside of constructors and (non-async) generator functions.
Expand All @@ -44,7 +44,5 @@ enum AsyncRewriterErrors {
*
* **Solution: Do not use calls directly in such functions. If necessary, place these calls in an inner 'async' function.**
*/
SyntheticAsyncIterableInAlwaysSyncContext = 'ASYNC-10013',
}

export { AsyncRewriterErrors };
SyntheticAsyncIterableInAlwaysSyncContext: 'ASYNC-10013',
} as const;
18 changes: 9 additions & 9 deletions packages/autocomplete/src/index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { completer, BASE_COMPLETIONS } from './';
import { signatures as shellSignatures, Topologies } from '@mongosh/shell-api';
import { signatures as shellSignatures } from '@mongosh/shell-api';

import { expect } from 'chai';

let collections: string[];
let databases: string[];
const standalone600 = {
topology: () => Topologies.Standalone,
topology: () => 'Standalone' as const,
apiVersionInfo: () => undefined,
connectionInfo: () => ({
is_atlas: false,
Expand All @@ -18,7 +18,7 @@ const standalone600 = {
getDatabaseCompletions: () => databases,
};
const standalone440 = {
topology: () => Topologies.Standalone,
topology: () => 'Standalone' as const,
apiVersionInfo: () => undefined,
connectionInfo: () => ({
is_atlas: false,
Expand All @@ -30,7 +30,7 @@ const standalone440 = {
getDatabaseCompletions: () => databases,
};
const apiStrictParams = {
topology: () => Topologies.Standalone,
topology: () => 'Standalone' as const,
apiVersionInfo: () => ({
version: '1',
strict: true,
Expand All @@ -41,7 +41,7 @@ const apiStrictParams = {
getDatabaseCompletions: () => databases,
};
const sharded440 = {
topology: () => Topologies.Sharded,
topology: () => 'Sharded' as const,
apiVersionInfo: () => undefined,
connectionInfo: () => ({
is_atlas: false,
Expand All @@ -54,7 +54,7 @@ const sharded440 = {
};

const standalone300 = {
topology: () => Topologies.Standalone,
topology: () => 'Standalone' as const,
apiVersionInfo: () => undefined,
connectionInfo: () => ({
is_atlas: false,
Expand All @@ -66,7 +66,7 @@ const standalone300 = {
getDatabaseCompletions: () => databases,
};
const datalake440 = {
topology: () => Topologies.Sharded,
topology: () => 'Sharded' as const,
apiVersionInfo: () => undefined,
connectionInfo: () => ({
is_atlas: true,
Expand All @@ -79,7 +79,7 @@ const datalake440 = {
};

const localAtlas600 = {
topology: () => Topologies.Standalone,
topology: () => 'Standalone' as const,
apiVersionInfo: () => undefined,
connectionInfo: () => ({
is_atlas: false,
Expand All @@ -100,7 +100,7 @@ const noParams = {
};

const emptyConnectionInfoParams = {
topology: () => Topologies.Standalone,
topology: () => 'Standalone' as const,
apiVersionInfo: () => undefined,
connectionInfo: () => ({}),
getCollectionCompletionsForCurrentDb: () => collections,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { ShellApiAutocompleter } from './shell-api-autocompleter';
import { expect } from 'chai';
import { Topologies } from '@mongosh/shell-api';
import type { AutocompleteParameters } from '@mongosh/autocomplete';
import type { AutocompletionContext } from '@mongodb-js/mongodb-ts-autocomplete';

const standalone440Parameters: AutocompleteParameters = {
topology: () => Topologies.Standalone,
topology: () => 'Standalone',
apiVersionInfo: () => undefined,
connectionInfo: () => ({
is_atlas: false,
Expand Down
2 changes: 1 addition & 1 deletion packages/build/src/barque.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ describe('Barque', function () {
});

it('platform is not linux', function () {
config.platform = 'macos';
config.platform = 'darwin';
try {
barque = new Barque(config);
} catch (e: any) {
Expand Down
10 changes: 2 additions & 8 deletions packages/build/src/barque.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,7 @@ import tmp from 'tmp-promise';
import util, { promisify } from 'util';
import type { PackageVariant, Config } from './config';
import semver from 'semver';
import {
getArch,
getDistro,
getDebArchName,
getRPMArchName,
Platform,
} from './config';
import { getArch, getDistro, getDebArchName, getRPMArchName } from './config';
import { withRetries } from './helpers';
import type {
PPARepository,
Expand Down Expand Up @@ -120,7 +114,7 @@ export class Barque {
private downloadedCuratorPromise: Promise<string> | undefined;

constructor(config: Config) {
if (config.platform !== Platform.Linux) {
if (config.platform !== 'linux') {
throw new Error('Barque publishing is only supported on linux platforms');
}

Expand Down
2 changes: 1 addition & 1 deletion packages/build/src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export interface Config {
notarySigningKeyName?: string;
notaryAuthToken?: string;
isCi?: boolean;
platform?: string;
platform?: NodeJS.Platform;
execNodeVersion: string;
packageVariant?: PackageVariant;
repo: {
Expand Down
6 changes: 1 addition & 5 deletions packages/build/src/config/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,4 @@
* Different from 'BuildVariant': platform is extracted from os.platform() and
* build variant is the host evergreen is building on.
*/
export enum Platform {
Windows = 'win32',
MacOs = 'darwin',
Linux = 'linux',
}
export type Platform = 'win32' | 'darwin' | 'linux';
19 changes: 14 additions & 5 deletions packages/build/src/evergreen/rest-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,21 @@ export interface EvergreenTask {
}

export class EvergreenApi {
public readonly apiBasepath: string;
public readonly apiUser: string;
public readonly apiKey: string;
private readonly fetch: typeof fetchFn;
constructor(
public readonly apiBasepath: string,
public readonly apiUser: string,
public readonly apiKey: string,
private readonly fetch: typeof fetchFn = fetchFn
) {}
apiBasepath: string,
apiUser: string,
apiKey: string,
fetch: typeof fetchFn = fetchFn
) {
this.apiBasepath = apiBasepath;
this.apiUser = apiUser;
this.apiKey = apiKey;
this.fetch = fetch;
}

public static async fromUserConfiguration(
pathToConfiguration = path.join(os.homedir(), '.evergreen.yml')
Expand Down
4 changes: 3 additions & 1 deletion packages/build/src/homebrew/publish-to-homebrew.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,20 @@ export type HomebrewPublisherConfig = {
};

export class HomebrewPublisher {
public config: HomebrewPublisherConfig;
readonly npmPackageSha256: typeof npmPackageSha256Fn;
readonly generateFormula: typeof generateUpdatedFormulaFn;
readonly updateHomebrewFork: typeof updateHomebrewForkFn;

constructor(
public config: HomebrewPublisherConfig,
config: HomebrewPublisherConfig,
{
npmPackageSha256 = npmPackageSha256Fn,
generateFormula = generateUpdatedFormulaFn,
updateHomebrewFork = updateHomebrewForkFn,
} = {}
) {
this.config = config;
this.npmPackageSha256 = npmPackageSha256;
this.generateFormula = generateFormula;
this.updateHomebrewFork = updateHomebrewFork;
Expand Down
25 changes: 19 additions & 6 deletions packages/build/src/publish-mongosh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,25 +48,38 @@ export async function publishMongosh(config: Config, octokit: Octokit) {
}

export class MongoshPublisher {
public config: Config;
public barque: Barque;
public mongoshGithubRepo: GithubRepo;
public packagePublisher: PackagePublisher;
public packageBumper: PackageBumper;
public homebrewPublisher: HomebrewPublisher;

private readonly getEvergreenArtifactUrl: typeof getArtifactUrlFn;
private readonly writeBuildInfo: typeof writeBuildInfoFn;
private readonly createAndPublishDownloadCenterConfig: typeof createAndPublishDownloadCenterConfigFn;
private readonly shouldDoPublicRelease: typeof shouldDoPublicReleaseFn;

constructor(
public config: Config,
public barque: Barque,
public mongoshGithubRepo: GithubRepo,
public packagePublisher: PackagePublisher,
public packageBumper: PackageBumper,
public homebrewPublisher: HomebrewPublisher,
config: Config,
barque: Barque,
mongoshGithubRepo: GithubRepo,
packagePublisher: PackagePublisher,
packageBumper: PackageBumper,
homebrewPublisher: HomebrewPublisher,
{
getEvergreenArtifactUrl = getArtifactUrlFn,
writeBuildInfo = writeBuildInfoFn,
createAndPublishDownloadCenterConfig = createAndPublishDownloadCenterConfigFn,
shouldDoPublicRelease = shouldDoPublicReleaseFn,
} = {}
) {
this.config = config;
this.barque = barque;
this.mongoshGithubRepo = mongoshGithubRepo;
this.packagePublisher = packagePublisher;
this.packageBumper = packageBumper;
this.homebrewPublisher = homebrewPublisher;
this.getEvergreenArtifactUrl = getEvergreenArtifactUrl;
this.writeBuildInfo = writeBuildInfo;
this.createAndPublishDownloadCenterConfig =
Expand Down
8 changes: 3 additions & 5 deletions packages/cli-repl/src/error-codes.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
/**
* @mongoshErrors
*/
enum CliReplErrors {
export const CliReplErrors = {
/**
* Signals that the currently installed Node version does not match the one expected by mongosh.
*
* See the output for further details on the required Node version.
*/
NodeVersionMismatch = 'CLIREPL-10001',
}

export { CliReplErrors };
NodeVersionMismatch: 'CLIREPL-10001',
} as const;
18 changes: 8 additions & 10 deletions packages/errors/src/common-errors.ts
Original file line number Diff line number Diff line change
@@ -1,49 +1,47 @@
/**
* @mongoshErrors
*/
enum CommonErrors {
export const CommonErrors = {
/**
* Signals calling an API method with an invalid argument.
*
* **Solution: See the error output for details on allowed argument values.**
*/
InvalidArgument = 'COMMON-10001',
InvalidArgument: 'COMMON-10001',

/**
* Signals calling an API method that is not allowed in the current state.
*
* **Solution: See the error output for details.**
*/
InvalidOperation = 'COMMON-10002',
InvalidOperation: 'COMMON-10002',

/**
* Signals calling an API method that has been deprecated or using an argument or option of an API method that has been deprecated
* and therefore is no longer supported.
*
* **Solution: See the error output for details on alternatives or consult the official documentation.**
*/
Deprecated = 'COMMON-10003',
Deprecated: 'COMMON-10003',

/**
* Signals an error while running a specific command against the database.
*
* **Solution: Check the error output for more details and ensure the database is healthy and available.**
*/
CommandFailed = 'COMMON-10004',
CommandFailed: 'COMMON-10004',

/**
* Signals an unexpected internal error of mongosh.
*
* **Please file a bug report for the `MONGOSH` project here: https://jira.mongodb.org.**
*/
UnexpectedInternalError = 'COMMON-90001',
UnexpectedInternalError: 'COMMON-90001',

/**
* Signals usage of a method that is not implemented yet.
*
* **See the error output for details.**
*/
NotImplemented = 'COMMON-90002',
}

export { CommonErrors };
NotImplemented: 'COMMON-90002',
} as const;
5 changes: 4 additions & 1 deletion packages/logging/src/analytics-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,12 @@ export interface MongoshAnalytics {
}

class Queue<T> {
private applyFn: (val: T) => void;
private queue: T[] = [];
private state: 'paused' | 'enabled' | 'disabled' = 'paused';
constructor(private applyFn: (val: T) => void) {}
constructor(applyFn: (val: T) => void) {
this.applyFn = applyFn;
}
push(val: T) {
switch (this.state) {
case 'paused':
Expand Down
Loading
Loading