@mongosh/browser-runtime-core 1.10.0 → 1.10.2

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/.depcheckrc ADDED
@@ -0,0 +1,13 @@
1
+ ignores:
2
+ - '@mongodb-js/tsconfig-mongosh'
3
+ - '@mongodb-js/eslint-config-mongosh'
4
+ - '@mongodb-js/prettier-config-devtools'
5
+ - '@typescript-eslint/parser'
6
+ - '@typescript-eslint/eslint-plugin'
7
+ - chai
8
+ - sinon-chai
9
+ - ts-sinon
10
+ - eslint-plugin-mocha
11
+ - eslint-config-mongodb-js
12
+ ignore-patterns:
13
+ - .eslintrc.js
package/.eslintrc.js CHANGED
@@ -1 +1,10 @@
1
- module.exports = require('../../config/eslintrc.base');
1
+ const { fixCygwinPath } = require('@mongodb-js/eslint-config-mongosh/utils');
2
+
3
+ module.exports = {
4
+ root: true,
5
+ extends: ['@mongodb-js/eslint-config-mongosh'],
6
+ parserOptions: {
7
+ tsconfigRootDir: fixCygwinPath(__dirname),
8
+ project: ['./tsconfig-lint.json'],
9
+ },
10
+ };
@@ -0,0 +1,6 @@
1
+ **/lib
2
+ **/dist
3
+ **/node_modules
4
+ **/test/fixtures
5
+ **/*.nocov*
6
+ **/*.wxs
@@ -0,0 +1 @@
1
+ "@mongodb-js/prettier-config-devtools"
package/AUTHORS CHANGED
@@ -9,3 +9,4 @@ Sergey Petushkov <petushkov.sergey@gmail.com>
9
9
  Michael Rose <michael_rose@gmx.de>
10
10
  github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
11
11
  Martin Rodriguez Reboredo <yakoyoku@gmail.com>
12
+ Le Roux Bodenstein <lerouxb@gmail.com>
@@ -1,4 +1,4 @@
1
- import { AutocompleteParameters } from '@mongosh/autocomplete';
1
+ import type { AutocompleteParameters } from '@mongosh/autocomplete';
2
2
  import type { Autocompleter, Completion } from './autocompleter';
3
3
  export declare class ShellApiAutocompleter implements Autocompleter {
4
4
  private parameters;
@@ -19,7 +19,7 @@ class ShellApiAutocompleter {
19
19
  }
20
20
  const entries = completions[0].map((completion) => {
21
21
  return {
22
- completion
22
+ completion,
23
23
  };
24
24
  });
25
25
  return entries;
@@ -1 +1 @@
1
- {"version":3,"file":"shell-api-autocompleter.js","sourceRoot":"","sources":["../../src/autocompleter/shell-api-autocompleter.ts"],"names":[],"mappings":";;;;;;AAAA,yEAAiF;AAGjF,MAAa,qBAAqB;IAGhC,YAAY,UAAkC;QAC5C,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,IAAY;QAC/B,IAAI,CAAC,IAAI,EAAE;YACT,OAAO,EAAE,CAAC;SACX;QAED,MAAM,WAAW,GAAG,MAAM,IAAA,sBAAgB,EAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;QAElE,IAAI,CAAC,WAAW,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE;YACvC,OAAO,EAAE,CAAC;SACX;QAED,MAAM,OAAO,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE;YAChD,OAAO;gBACL,UAAU;aACX,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AA1BD,sDA0BC"}
1
+ {"version":3,"file":"shell-api-autocompleter.js","sourceRoot":"","sources":["../../src/autocompleter/shell-api-autocompleter.ts"],"names":[],"mappings":";;;;;;AACA,yEAAqD;AAGrD,MAAa,qBAAqB;IAGhC,YAAY,UAAkC;QAC5C,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,IAAY;QAC/B,IAAI,CAAC,IAAI,EAAE;YACT,OAAO,EAAE,CAAC;SACX;QAED,MAAM,WAAW,GAAG,MAAM,IAAA,sBAAgB,EAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;QAElE,IAAI,CAAC,WAAW,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE;YACvC,OAAO,EAAE,CAAC;SACX;QAED,MAAM,OAAO,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE;YAChD,OAAO;gBACL,UAAU;aACX,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AA1BD,sDA0BC"}
package/lib/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export { Runtime, RuntimeEvaluationListener, RuntimeEvaluationResult } from './runtime';
2
- export { OpenContextRuntime, ContextValue, InterpreterEnvironment } from './open-context-runtime';
1
+ export { Runtime, RuntimeEvaluationListener, RuntimeEvaluationResult, } from './runtime';
2
+ export { OpenContextRuntime, ContextValue, InterpreterEnvironment, } from './open-context-runtime';
3
3
  export { Autocompleter, Completion } from './autocompleter/autocompleter';
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AACA,+DAAkG;AAAzF,0HAAA,kBAAkB,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAKA,+DAIgC;AAH9B,0HAAA,kBAAkB,OAAA"}
@@ -1,8 +1,8 @@
1
- import { Completion } from './autocompleter/autocompleter';
2
- import { ServiceProvider } from '@mongosh/service-provider-core';
3
- import { Runtime, RuntimeEvaluationResult, RuntimeEvaluationListener } from './runtime';
1
+ import type { Completion } from './autocompleter/autocompleter';
2
+ import type { ServiceProvider } from '@mongosh/service-provider-core';
3
+ import type { Runtime, RuntimeEvaluationResult, RuntimeEvaluationListener } from './runtime';
4
4
  import type { MongoshBus } from '@mongosh/types';
5
- export declare type ContextValue = any;
5
+ export type ContextValue = any;
6
6
  export interface InterpreterEnvironment {
7
7
  sloppyEval(code: string): ContextValue;
8
8
  getContextObject(): ContextValue;
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AAI,CAAC,aAAa,CAAC,qBAAqB,CAAC,QAAQ,CAAC,CAAC;QACnD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,cAAc;;QAClB,MAAA,IAAI,CAAC,4BAA4B,oCAAjC,IAAI,CAAC,4BAA4B,GAC/B,IAAI,CAAC,aAAa,CAAC,mBAAmB,EAAE,EAAC;QAC3C,MAAM,IAAI,CAAC,4BAA4B,CAAC;QACxC,OAAO,MAAM,IAAI,CAAC,aAAa,CAAC,gBAAgB,EAAE,CAAC;IACrD,CAAC;CACF;AAhED,gDAgEC"}
package/lib/runtime.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { Completion } from './autocompleter/autocompleter';
2
- import { ShellResult, EvaluationListener } from '@mongosh/shell-evaluator';
3
- export declare type ContextValue = any;
4
- export declare type RuntimeEvaluationResult = Pick<ShellResult, 'type' | 'printable' | 'source'>;
1
+ import type { Completion } from './autocompleter/autocompleter';
2
+ import type { ShellResult, EvaluationListener } from '@mongosh/shell-evaluator';
3
+ export type ContextValue = any;
4
+ export type RuntimeEvaluationResult = Pick<ShellResult, 'type' | 'printable' | 'source'>;
5
5
  export interface RuntimeEvaluationListener extends EvaluationListener {
6
6
  onPrint?: (value: RuntimeEvaluationResult[]) => Promise<void> | void;
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mongosh/browser-runtime-core",
3
- "version": "1.10.0",
3
+ "version": "1.10.2",
4
4
  "description": "Mongosh browser runtime core",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -17,11 +17,15 @@
17
17
  "scripts": {
18
18
  "test": "mocha -r \"../../scripts/import-expansions.js\" --timeout 60000 -r ts-node/register \"./{src,lib}/**/*.spec.ts\"",
19
19
  "test-ci": "node ../../scripts/run-if-package-requested.js npm test",
20
- "lint": "eslint --report-unused-disable-directives \"./{src,test}/**/*.{js,ts,tsx}\"",
21
- "check": "npm run lint && depcheck --skip-missing=true",
20
+ "eslint": "eslint",
21
+ "lint": "npm run eslint . && npm run prettier -- --check .",
22
+ "check": "npm run lint && npm run depcheck",
23
+ "depcheck": "depcheck",
22
24
  "preprepublish": "rimraf ./lib",
23
- "prepublish": "npm run compile-ts",
24
- "compile-ts": "tsc -p tsconfig.json"
25
+ "prepublish": "npm run compile",
26
+ "compile": "tsc -p tsconfig.json",
27
+ "prettier": "prettier",
28
+ "reformat": "npm run prettier -- --write . && npm run eslint --fix"
25
29
  },
26
30
  "author": "",
27
31
  "license": "Apache-2.0",
@@ -32,14 +36,21 @@
32
36
  "unitTestsOnly": true
33
37
  },
34
38
  "devDependencies": {
35
- "@mongosh/types": "1.10.0",
39
+ "@mongodb-js/eslint-config-mongosh": "1.10.2",
40
+ "@mongodb-js/prettier-config-devtools": "^1.0.1",
41
+ "@mongodb-js/tsconfig-mongosh": "1.10.2",
42
+ "@mongosh/types": "1.10.2",
43
+ "bson": "^5.3.0",
44
+ "depcheck": "^1.4.3",
45
+ "eslint": "^7.25.0",
46
+ "prettier": "^2.8.8",
36
47
  "rimraf": "^3.0.2"
37
48
  },
38
49
  "dependencies": {
39
- "@mongosh/autocomplete": "1.10.0",
40
- "@mongosh/service-provider-core": "1.10.0",
41
- "@mongosh/shell-api": "1.10.0",
42
- "@mongosh/shell-evaluator": "1.10.0"
50
+ "@mongosh/autocomplete": "1.10.2",
51
+ "@mongosh/service-provider-core": "1.10.2",
52
+ "@mongosh/shell-api": "1.10.2",
53
+ "@mongosh/shell-evaluator": "1.10.2"
43
54
  },
44
- "gitHead": "6a6f97712a596a21c61408dfb925e729306030f8"
55
+ "gitHead": "9351a54cc24def10a97fe7f8c7b455c02fdce62e"
45
56
  }
@@ -2,7 +2,6 @@
2
2
  * A completion item
3
3
  */
4
4
  export interface Completion {
5
-
6
5
  /**
7
6
  * The completed text (ie. db.coll1.f -> db.coll1.find).
8
7
  */
@@ -13,7 +12,6 @@ export interface Completion {
13
12
  * Interface for an Autocompleter
14
13
  */
15
14
  export interface Autocompleter {
16
-
17
15
  /**
18
16
  * Returns completions for the code passed as argument.
19
17
  *
@@ -8,52 +8,50 @@ const standalone440 = {
8
8
  connectionInfo: () => ({
9
9
  is_atlas: false,
10
10
  is_data_federation: false,
11
- server_version: '4.4.0'
11
+ server_version: '4.4.0',
12
12
  }),
13
13
  getCollectionCompletionsForCurrentDb: () => ['bananas'],
14
- getDatabaseCompletions: () => ['databaseOne']
14
+ getDatabaseCompletions: () => ['databaseOne'],
15
15
  };
16
16
 
17
- describe('Autocompleter', () => {
18
- describe('getCompletions', () => {
17
+ describe('Autocompleter', function () {
18
+ describe('getCompletions', function () {
19
19
  let autocompleter: ShellApiAutocompleter;
20
20
 
21
- beforeEach(() => {
21
+ beforeEach(function () {
22
22
  autocompleter = new ShellApiAutocompleter(standalone440);
23
23
  });
24
24
 
25
- it('returns completions for text before cursor', async() => {
25
+ it('returns completions for text before cursor', async function () {
26
26
  const completions = await autocompleter.getCompletions('db.coll1.');
27
27
 
28
28
  expect(completions).to.deep.contain({
29
- completion: 'db.coll1.find'
29
+ completion: 'db.coll1.find',
30
30
  });
31
31
  });
32
32
 
33
- it('returns full completion value with text after dot', async() => {
33
+ it('returns full completion value with text after dot', async function () {
34
34
  const completions = await autocompleter.getCompletions('db.coll1.f');
35
35
 
36
36
  expect(completions).to.deep.contain({
37
- completion: 'db.coll1.find'
37
+ completion: 'db.coll1.find',
38
38
  });
39
39
  });
40
40
 
41
- it('returns collection names value with text after dot', async() => {
41
+ it('returns collection names value with text after dot', async function () {
42
42
  const completions = await autocompleter.getCompletions('db.b');
43
43
 
44
44
  expect(completions).to.deep.contain({
45
- completion: 'db.bananas'
45
+ completion: 'db.bananas',
46
46
  });
47
47
  });
48
48
 
49
- it('returns database names after use', async() => {
49
+ it('returns database names after use', async function () {
50
50
  const completions = await autocompleter.getCompletions('use da');
51
51
 
52
52
  expect(completions).to.deep.contain({
53
- completion: 'use databaseOne'
53
+ completion: 'use databaseOne',
54
54
  });
55
55
  });
56
56
  });
57
57
  });
58
-
59
-
@@ -1,4 +1,5 @@
1
- import cliReplCompleter, { AutocompleteParameters } from '@mongosh/autocomplete';
1
+ import type { AutocompleteParameters } from '@mongosh/autocomplete';
2
+ import cliReplCompleter from '@mongosh/autocomplete';
2
3
  import type { Autocompleter, Completion } from './autocompleter';
3
4
 
4
5
  export class ShellApiAutocompleter implements Autocompleter {
@@ -21,7 +22,7 @@ export class ShellApiAutocompleter implements Autocompleter {
21
22
 
22
23
  const entries = completions[0].map((completion) => {
23
24
  return {
24
- completion
25
+ completion,
25
26
  };
26
27
  });
27
28
 
package/src/index.ts CHANGED
@@ -1,3 +1,11 @@
1
- export { Runtime, RuntimeEvaluationListener, RuntimeEvaluationResult } from './runtime';
2
- export { OpenContextRuntime, ContextValue, InterpreterEnvironment } from './open-context-runtime';
1
+ export {
2
+ Runtime,
3
+ RuntimeEvaluationListener,
4
+ RuntimeEvaluationResult,
5
+ } from './runtime';
6
+ export {
7
+ OpenContextRuntime,
8
+ ContextValue,
9
+ InterpreterEnvironment,
10
+ } from './open-context-runtime';
3
11
  export { Autocompleter, Completion } from './autocompleter/autocompleter';
@@ -1,14 +1,16 @@
1
1
  import bson from 'bson';
2
2
  import vm from 'vm';
3
- import { OpenContextRuntime, InterpreterEnvironment } from './';
3
+ import type { InterpreterEnvironment } from './';
4
+ import { OpenContextRuntime } from './';
4
5
  import type { MongoshBus } from '@mongosh/types';
5
- import { ServiceProvider } from '@mongosh/service-provider-core';
6
+ import type { ServiceProvider } from '@mongosh/service-provider-core';
6
7
  import chai, { expect } from 'chai';
7
8
  import sinonChai from 'sinon-chai';
8
- import { StubbedInstance, stubInterface } from 'ts-sinon';
9
+ import type { StubbedInstance } from 'ts-sinon';
10
+ import { stubInterface } from 'ts-sinon';
9
11
  chai.use(sinonChai);
10
12
 
11
- describe('OpenContextRuntime', () => {
13
+ describe('OpenContextRuntime', function () {
12
14
  let sp: StubbedInstance<ServiceProvider>;
13
15
  let interpreterEnvironment: InterpreterEnvironment;
14
16
  let bus: MongoshBus;
@@ -23,9 +25,8 @@ describe('OpenContextRuntime', () => {
23
25
  }
24
26
 
25
27
  for (const evaluator of ['eval', 'vm']) {
26
- // eslint-disable-next-line no-loop-func
27
- context(`with ${evaluator} evaluator`, () => {
28
- beforeEach(() => {
28
+ context(`with ${evaluator} evaluator`, function () {
29
+ beforeEach(function () {
29
30
  sp = stubInterface<ServiceProvider>();
30
31
  sp.initialDb = 'test';
31
32
  sp.bsonLibrary = bson;
@@ -36,88 +37,52 @@ describe('OpenContextRuntime', () => {
36
37
  const context = vm.createContext();
37
38
  interpreterEnvironment = {
38
39
  sloppyEval(code: string): any {
39
- return evaluator === 'eval' ?
40
- vm.runInContext('globalThis.eval', context)(code) :
41
- vm.runInContext(code, context);
40
+ return evaluator === 'eval'
41
+ ? vm.runInContext('globalThis.eval', context)(code)
42
+ : vm.runInContext(code, context);
42
43
  },
43
44
 
44
45
  getContextObject(): any {
45
46
  return interpreterEnvironment.sloppyEval('globalThis');
46
- }
47
+ },
47
48
  };
48
49
  runtime = new OpenContextRuntime(sp, interpreterEnvironment, bus);
49
50
  });
50
51
 
51
- describe('basic evaluation', () => {
52
- it('evaluates an integer literal', async() => {
53
- expect(
54
- await testEvaluate(
55
- '1'
56
- )
57
- ).to.equal(1);
52
+ describe('basic evaluation', function () {
53
+ it('evaluates an integer literal', async function () {
54
+ expect(await testEvaluate('1')).to.equal(1);
58
55
  });
59
56
 
60
- it('evaluates an string literal', async() => {
61
- expect(
62
- await testEvaluate(
63
- '"some text"'
64
- )
65
- ).to.equal('some text');
57
+ it('evaluates an string literal', async function () {
58
+ expect(await testEvaluate('"some text"')).to.equal('some text');
66
59
  });
67
60
 
68
- it('allows to set and evaluate a variable', async() => {
69
- expect(
70
- await testEvaluate(
71
- 'x = 1',
72
- 'x'
73
- )
74
- ).to.equal(1);
61
+ it('allows to set and evaluate a variable', async function () {
62
+ expect(await testEvaluate('x = 1', 'x')).to.equal(1);
75
63
  });
76
64
 
77
- it('resolve promises before return', async() => {
78
- expect(
79
- await testEvaluate(
80
- 'Promise.resolve(1)'
81
- )
82
- ).to.equal(1);
65
+ it('resolve promises before return', async function () {
66
+ expect(await testEvaluate('Promise.resolve(1)')).to.equal(1);
83
67
  });
84
68
 
85
- it('evaluates object literal after other statements as block', async() => {
86
- expect(
87
- await testEvaluate(
88
- ';{x: 1}'
89
- )
90
- ).to.equal(1);
69
+ it('evaluates object literal after other statements as block', async function () {
70
+ expect(await testEvaluate(';{x: 1}')).to.equal(1);
91
71
  });
92
72
 
93
- it('can declare a top level variable with let', async() => {
94
- expect(
95
- await testEvaluate(
96
- 'let x = 1',
97
- 'x'
98
- )
99
- ).to.equal(1);
73
+ it('can declare a top level variable with let', async function () {
74
+ expect(await testEvaluate('let x = 1', 'x')).to.equal(1);
100
75
  });
101
76
 
102
- it('can declare a top level variable with const', async() => {
103
- expect(
104
- await testEvaluate(
105
- 'const x = 1',
106
- 'x'
107
- )
108
- ).to.equal(1);
77
+ it('can declare a top level variable with const', async function () {
78
+ expect(await testEvaluate('const x = 1', 'x')).to.equal(1);
109
79
  });
110
80
 
111
- it('can declare a top level variable with var', async() => {
112
- expect(
113
- await testEvaluate(
114
- 'var x = 1',
115
- 'x'
116
- )
117
- ).to.equal(1);
81
+ it('can declare a top level variable with var', async function () {
82
+ expect(await testEvaluate('var x = 1', 'x')).to.equal(1);
118
83
  });
119
84
 
120
- it('can declare a top level class', async() => {
85
+ it('can declare a top level class', async function () {
121
86
  expect(
122
87
  await testEvaluate(
123
88
  'class A { doSomething() { return 1; } }',
@@ -126,8 +91,7 @@ describe('OpenContextRuntime', () => {
126
91
  ).to.equal(1);
127
92
  });
128
93
 
129
-
130
- it('can declare a top level function', async() => {
94
+ it('can declare a top level function', async function () {
131
95
  expect(
132
96
  await testEvaluate(
133
97
  'function sum(a, b) { return a + b; }',
@@ -136,7 +100,7 @@ describe('OpenContextRuntime', () => {
136
100
  ).to.equal(3);
137
101
  });
138
102
 
139
- it('can redeclare a top level function as function', async() => {
103
+ it('can redeclare a top level function as function', async function () {
140
104
  expect(
141
105
  await testEvaluate(
142
106
  'function f() { return 1; }',
@@ -146,7 +110,7 @@ describe('OpenContextRuntime', () => {
146
110
  ).to.equal(2);
147
111
  });
148
112
 
149
- it('can redeclare a top level function as var', async() => {
113
+ it('can redeclare a top level function as var', async function () {
150
114
  expect(
151
115
  await testEvaluate(
152
116
  'function sum(a, b) { return a + b; }',
@@ -156,19 +120,17 @@ describe('OpenContextRuntime', () => {
156
120
  ).to.equal(1);
157
121
  });
158
122
 
159
- it('can run shell commands', async() => {
123
+ it('can run shell commands', async function () {
160
124
  expect(
161
- await testEvaluate(
162
- 'db.adminCommand({ ping: 1 })'
163
- )
125
+ await testEvaluate('db.adminCommand({ ping: 1 })')
164
126
  ).to.deep.equal({ ok: 1 });
165
127
  });
166
128
 
167
- it('can create BSON objects', async() => {
129
+ it('can create BSON objects', async function () {
168
130
  expect(
169
- JSON.parse(await testEvaluate(
170
- 'EJSON.stringify(Timestamp({ t: 1, i: 2 }))'
171
- ))
131
+ JSON.parse(
132
+ await testEvaluate('EJSON.stringify(Timestamp({ t: 1, i: 2 }))')
133
+ )
172
134
  ).to.deep.equal({ $timestamp: { t: 1, i: 2 } });
173
135
  });
174
136
  });
@@ -1,10 +1,10 @@
1
- import { Completion } from './autocompleter/autocompleter';
2
- import { ServiceProvider } from '@mongosh/service-provider-core';
1
+ import type { Completion } from './autocompleter/autocompleter';
2
+ import type { ServiceProvider } from '@mongosh/service-provider-core';
3
3
  import { ShellApiAutocompleter } from './autocompleter/shell-api-autocompleter';
4
- import {
4
+ import type {
5
5
  Runtime,
6
6
  RuntimeEvaluationResult,
7
- RuntimeEvaluationListener
7
+ RuntimeEvaluationListener,
8
8
  } from './runtime';
9
9
  import { EventEmitter } from 'events';
10
10
  import { ShellInstanceState } from '@mongosh/shell-api';
@@ -41,7 +41,10 @@ export class OpenContextRuntime implements Runtime {
41
41
  messageBus?: MongoshBus
42
42
  ) {
43
43
  this.interpreterEnvironment = interpreterEnvironment;
44
- this.instanceState = new ShellInstanceState(serviceProvider, messageBus || new EventEmitter());
44
+ this.instanceState = new ShellInstanceState(
45
+ serviceProvider,
46
+ messageBus || new EventEmitter()
47
+ );
45
48
  this.instanceState.isInteractive = true;
46
49
  this.shellEvaluator = new ShellEvaluator(this.instanceState);
47
50
  this.instanceState.setCtx(this.interpreterEnvironment.getContextObject());
@@ -49,8 +52,11 @@ export class OpenContextRuntime implements Runtime {
49
52
 
50
53
  async getCompletions(code: string): Promise<Completion[]> {
51
54
  if (!this.autocompleter) {
52
- this.autocompleter = new ShellApiAutocompleter(this.instanceState.getAutocompleteParameters());
53
- this.updatedConnectionInfoPromise ??= this.instanceState.fetchConnectionInfo();
55
+ this.autocompleter = new ShellApiAutocompleter(
56
+ this.instanceState.getAutocompleteParameters()
57
+ );
58
+ this.updatedConnectionInfoPromise ??=
59
+ this.instanceState.fetchConnectionInfo();
54
60
  await this.updatedConnectionInfoPromise;
55
61
  }
56
62
 
@@ -58,7 +64,9 @@ export class OpenContextRuntime implements Runtime {
58
64
  }
59
65
 
60
66
  async evaluate(code: string): Promise<RuntimeEvaluationResult> {
61
- const evalFn = this.interpreterEnvironment.sloppyEval.bind(this.interpreterEnvironment);
67
+ const evalFn = this.interpreterEnvironment.sloppyEval.bind(
68
+ this.interpreterEnvironment
69
+ );
62
70
  const { type, printable, source } = await this.shellEvaluator.customEval(
63
71
  evalFn,
64
72
  code,
@@ -68,7 +76,9 @@ export class OpenContextRuntime implements Runtime {
68
76
  return { type, printable, source };
69
77
  }
70
78
 
71
- setEvaluationListener(listener: RuntimeEvaluationListener): RuntimeEvaluationListener | null {
79
+ setEvaluationListener(
80
+ listener: RuntimeEvaluationListener
81
+ ): RuntimeEvaluationListener | null {
72
82
  const prev = this.evaluationListener;
73
83
  this.evaluationListener = listener;
74
84
  this.instanceState.setEvaluationListener(listener);
@@ -76,7 +86,8 @@ export class OpenContextRuntime implements Runtime {
76
86
  }
77
87
 
78
88
  async getShellPrompt(): Promise<string> {
79
- this.updatedConnectionInfoPromise ??= this.instanceState.fetchConnectionInfo();
89
+ this.updatedConnectionInfoPromise ??=
90
+ this.instanceState.fetchConnectionInfo();
80
91
  await this.updatedConnectionInfoPromise;
81
92
  return await this.instanceState.getDefaultPrompt();
82
93
  }
package/src/runtime.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { Completion } from './autocompleter/autocompleter';
2
- import { ShellResult, EvaluationListener } from '@mongosh/shell-evaluator';
1
+ import type { Completion } from './autocompleter/autocompleter';
2
+ import type { ShellResult, EvaluationListener } from '@mongosh/shell-evaluator';
3
3
 
4
4
  export type ContextValue = any;
5
5
 
@@ -0,0 +1,5 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "include": ["**/*"],
4
+ "exclude": ["node_modules", "dist", "lib"]
5
+ }
package/tsconfig.json CHANGED
@@ -1,12 +1,8 @@
1
1
  {
2
- "extends": "../../config/tsconfig.base.json",
2
+ "extends": "@mongodb-js/tsconfig-mongosh/tsconfig.common.json",
3
3
  "compilerOptions": {
4
4
  "outDir": "./lib"
5
5
  },
6
- "include": [
7
- "./src/**/*"
8
- ],
9
- "exclude": [
10
- "./src/**/*.spec.*"
11
- ]
6
+ "include": ["src/**/*"],
7
+ "exclude": ["./src/**/*.spec.*"]
12
8
  }
@@ -1,8 +0,0 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "include": [
4
- "./src/**/*",
5
- "./test/**/*"
6
- ],
7
- "exclude": []
8
- }