@mongosh/node-runtime-worker-thread 1.10.5 → 2.0.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.
@@ -1 +1 @@
1
- {"version":3,"file":"worker-runtime.js","sourceRoot":"","sources":["../src/worker-runtime.ts"],"names":[],"mappings":";;AAGA,mDAA0D;AAO1D,gFAAoE;AAEpE,8EAA0E;AAC1E,+BAAgD;AAChD,6CAGsB;AAGtB,iCAA8B;AAE9B,6CAA+C;AAM/C,IAAI,CAAC,2BAAU,IAAI,6BAAY,EAAE;IAC/B,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;CACvE;AAED,IAAI,OAAO,GAAmB,IAAI,CAAC;AACnC,IAAI,QAAQ,GAA2B,IAAI,CAAC;AAE5C,MAAM,cAAc,GAAG,IAAI,WAAI,EAAE,CAAC;AAElC,SAAS,aAAa,CAAC,UAAkB;IACvC,IAAI,CAAC,OAAO,EAAE;QACZ,MAAM,IAAI,KAAK,CACb,eAAe,UAAU,oCAAoC,CAC9D,CAAC;KACH;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAMD,MAAM,kBAAkB,GAAG,IAAA,kBAAY,EACrC;IACE,SAAS;IACT,UAAU;IACV,WAAW;IACX,WAAW;IACX,aAAa;IACb,gBAAgB;IAChB,mBAAmB;IACnB,gBAAgB;IAChB,QAAQ;IACR,oBAAoB;CACrB,EACD,2BAAU,EACV;IACE,OAAO,EAAE,UACP,OAAkC;QAMlC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,sCAAyB,CAAC,CAAC,CAAC;IAClD,CAAC;CACF,CACF,CAAC;AAEF,MAAM,UAAU,GAAe,MAAM,CAAC,MAAM,CAC1C,IAAA,kBAAY,EAAC,CAAC,MAAM,CAAC,EAAE,2BAAU,CAAC,EAClC;IACE,EAAE;QACA,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;IACzE,CAAC;IACD,IAAI;QACF,MAAM,I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Ac,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;SACzE;gBAAS;YACR,cAAc,CAAC,MAAM,EAAE,CAAC;SACzB;QAED,IAAI,cAAc,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE;YACxC,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;SAC3D;QAED,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,WAAW,KAAK,IAAI,EAAE;YACzD,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;SACrD;QAED,OAAO,IAAA,sCAAyB,EAAC,MAAM,CAAC,CAAC;IAC3C,CAAC;IAED,cAAc,CAAC,IAAY;QACzB,OAAO,aAAa,CAAC,gBAAgB,CAAC,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;IAC9D,CAAC;IAED,cAAc;QACZ,OAAO,aAAa,CAAC,gBAAgB,CAAC,CAAC,cAAc,EAAE,CAAC;IAC1D,CAAC;IAED,qBAAqB;QACnB,MAAM,IAAI,KAAK,CACb,mEAAmE,CACpE,CAAC;IACJ,CAAC;IAED,SAAS;QACP,OAAO,cAAc,CAAC,MAAM,EAAE,CAAC;IACjC,CAAC;CACF,CAAC;AAMF,2BAAU,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;AAE/B,IAAA,eAAS,EAAC,aAAa,EAAE,2BAAU,CAAC,CAAC;AAErC,OAAO,CAAC,QAAQ,CAAC,GAAG,EAAE;IACpB,IAAI,2BAAU,EAAE;QACd,2BAAU,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;KACjC;AACH,CAAC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mongosh/node-runtime-worker-thread",
3
- "version": "1.10.5",
3
+ "version": "2.0.0",
4
4
  "description": "MongoDB shell runtime that lives in a worker thread",
5
5
  "homepage": "https://github.com/mongodb-js/mongosh",
6
6
  "license": "Apache-2.0",
@@ -20,6 +20,8 @@
20
20
  "test": "cross-env TS_NODE_PROJECT=./tsconfig.test.json mocha -r \"../../scripts/import-expansions.js\" --timeout 15000 -r ts-node/register \"./src/**/*.spec.ts\"",
21
21
  "pretest-ci": "node ../../scripts/run-if-package-requested.js npm run webpack-build -- --no-stats --no-devtool",
22
22
  "test-ci": "node ../../scripts/run-if-package-requested.js npm test",
23
+ "test-coverage": "nyc --no-clean --cwd ../.. --reporter=none npm run test",
24
+ "test-ci-coverage": "nyc --no-clean --cwd ../.. --reporter=none npm run test-ci",
23
25
  "eslint": "eslint",
24
26
  "lint": "npm run eslint . && npm run prettier -- --check .",
25
27
  "check": "npm run lint && npm run depcheck",
@@ -32,15 +34,15 @@
32
34
  "reformat": "npm run prettier -- --write . && npm run eslint --fix"
33
35
  },
34
36
  "devDependencies": {
35
- "@mongodb-js/eslint-config-mongosh": "1.10.5",
37
+ "@mongodb-js/eslint-config-mongosh": "^1.0.0",
36
38
  "@mongodb-js/prettier-config-devtools": "^1.0.1",
37
- "@mongodb-js/tsconfig-mongosh": "1.10.5",
38
- "@mongosh/browser-runtime-core": "1.10.5",
39
- "@mongosh/browser-runtime-electron": "1.10.5",
40
- "@mongosh/service-provider-core": "1.10.5",
41
- "@mongosh/service-provider-server": "1.10.5",
42
- "@mongosh/types": "1.10.5",
43
- "bson": "^5.3.0",
39
+ "@mongodb-js/tsconfig-mongosh": "^1.0.0",
40
+ "@mongosh/browser-runtime-core": "2.0.0",
41
+ "@mongosh/browser-runtime-electron": "2.0.0",
42
+ "@mongosh/service-provider-core": "2.0.0",
43
+ "@mongosh/service-provider-server": "2.0.0",
44
+ "@mongosh/types": "2.0.0",
45
+ "bson": "^6.0.0",
44
46
  "depcheck": "^1.4.3",
45
47
  "eslint": "^7.25.0",
46
48
  "mocha": "^10.2.0",
@@ -52,5 +54,5 @@
52
54
  "interruptor": "^1.0.1",
53
55
  "system-ca": "^1.0.2"
54
56
  },
55
- "gitHead": "bb658a0758c886a751f0798df7ce805a3fe911c4"
57
+ "gitHead": "60053aa2f37dc6c3e4fe059e806565ec51ece9e8"
56
58
  }
@@ -13,7 +13,6 @@ export class ChildProcessEvaluationListener {
13
13
  >;
14
14
 
15
15
  constructor(workerRuntime: WorkerRuntime, childProcess: ChildProcess) {
16
- // @ts-expect-error TODO(MONGOSH-1506) fix the typing
17
16
  this.exposedListener = exposeAll(
18
17
  {
19
18
  onPrompt(question, type) {
package/src/index.spec.ts CHANGED
@@ -3,7 +3,7 @@ import chai, { expect } from 'chai';
3
3
  import sinon from 'sinon';
4
4
  import sinonChai from 'sinon-chai';
5
5
  import type { MongoshBus } from '@mongosh/types';
6
- import { startTestServer } from '../../../testing/integration-testing-hooks';
6
+ import { startSharedTestServer } from '../../../testing/integration-testing-hooks';
7
7
  import { WorkerRuntime } from '../dist/index';
8
8
 
9
9
  import type { DevtoolsConnectOptions } from '@mongosh/service-provider-server';
@@ -148,7 +148,7 @@ describe('WorkerRuntime', function () {
148
148
  });
149
149
 
150
150
  describe('getCompletions', function () {
151
- const testServer = startTestServer('shared');
151
+ const testServer = startSharedTestServer();
152
152
 
153
153
  it('should return completions', async function () {
154
154
  runtime = new WorkerRuntime(
@@ -162,7 +162,7 @@ describe('WorkerRuntime', function () {
162
162
  });
163
163
 
164
164
  describe('getShellPrompt', function () {
165
- const testServer = startTestServer('shared');
165
+ const testServer = startSharedTestServer();
166
166
 
167
167
  it('should return prompt when connected to the server', async function () {
168
168
  runtime = new WorkerRuntime(
@@ -195,7 +195,7 @@ describe('WorkerRuntime', function () {
195
195
  });
196
196
 
197
197
  describe('eventEmitter', function () {
198
- const testServer = startTestServer('shared');
198
+ const testServer = startSharedTestServer();
199
199
 
200
200
  it('should propagate emitted events from worker', async function () {
201
201
  const eventEmitter = createMockEventEmitter();
package/src/rpc.spec.ts CHANGED
@@ -28,7 +28,7 @@ function sleep(ms: number) {
28
28
  describe('rpc helpers', function () {
29
29
  describe('serialize', function () {
30
30
  it('returns base64 representation of an input', function () {
31
- expect(serialize('Hello')).to.equal('data:;base64,/w0iBUhlbGxv');
31
+ expect(serialize('Hello')).to.match(/data:;base64,\/w[08]iBUhlbGxv/);
32
32
  });
33
33
  });
34
34
 
@@ -25,7 +25,7 @@ export default function spawnChildFromSource(
25
25
  _stdout: StdioNull | StdioPipe = 'inherit',
26
26
  _stderr: StdioNull | StdioPipe = 'inherit'
27
27
  ): Promise<ChildProcess> {
28
- return new Promise(async (resolve, reject) => {
28
+ return new Promise((resolve, reject) => {
29
29
  const readyToken = Date.now().toString(32);
30
30
 
31
31
  const childProcess = spawn(process.execPath, {
@@ -34,11 +34,16 @@ export default function spawnChildFromSource(
34
34
  });
35
35
 
36
36
  if (!childProcess.stdin) {
37
- await kill(childProcess);
38
-
39
- return reject(
40
- new Error("Can't write src to the spawned process, missing stdin")
41
- );
37
+ kill(childProcess)
38
+ .then(() => {
39
+ reject(
40
+ new Error("Can't write src to the spawned process, missing stdin")
41
+ );
42
+ })
43
+ .catch((err: any) => {
44
+ reject(err);
45
+ });
46
+ return;
42
47
  }
43
48
 
44
49
  // eslint-disable-next-line prefer-const
@@ -5,7 +5,7 @@ import chai, { expect } from 'chai';
5
5
  import sinonChai from 'sinon-chai';
6
6
  import sinon from 'sinon';
7
7
  import { EJSON, ObjectId } from 'bson';
8
- import { startTestServer } from '../../../testing/integration-testing-hooks';
8
+ import { startSharedTestServer } from '../../../testing/integration-testing-hooks';
9
9
  import type { Caller, Exposed } from './rpc';
10
10
  import { cancel, close, createCaller, exposeAll } from './rpc';
11
11
  import { deserializeEvaluationResult } from './serializer';
@@ -91,7 +91,7 @@ describe('worker', function () {
91
91
  expect(err).to.be.instanceof(Error);
92
92
  expect(err)
93
93
  .to.have.property('message')
94
- .match(/Can\'t call evaluate before shell runtime is initiated/);
94
+ .match(/Can't call evaluate before shell runtime is initiated/);
95
95
  });
96
96
 
97
97
  describe('evaluate', function () {
@@ -169,7 +169,7 @@ describe('worker', function () {
169
169
  });
170
170
 
171
171
  describe('shell-api results', function () {
172
- const testServer = startTestServer('shared');
172
+ const testServer = startSharedTestServer();
173
173
  const db = `test-db-${Date.now().toString(16)}`;
174
174
  let exposed: Exposed<unknown>;
175
175
 
@@ -455,14 +455,14 @@ describe('worker', function () {
455
455
  expect(err)
456
456
  .to.have.property('message')
457
457
  .match(
458
- /Can\'t run another evaluation while the previous is not finished/
458
+ /Can't run another evaluation while the previous is not finished/
459
459
  );
460
460
  });
461
461
  });
462
462
  });
463
463
 
464
464
  describe('getShellPrompt', function () {
465
- const testServer = startTestServer('shared');
465
+ const testServer = startSharedTestServer();
466
466
 
467
467
  it('should return prompt when connected to the server', async function () {
468
468
  const { init, getShellPrompt } = caller;
@@ -476,7 +476,7 @@ describe('worker', function () {
476
476
  });
477
477
 
478
478
  describe('getCompletions', function () {
479
- const testServer = startTestServer('shared');
479
+ const testServer = startSharedTestServer();
480
480
 
481
481
  it('should return completions', async function () {
482
482
  const { init, getCompletions } = caller;
@@ -38,7 +38,7 @@ const evaluationLock = new Lock();
38
38
  function ensureRuntime(methodName: string): Runtime {
39
39
  if (!runtime) {
40
40
  throw new Error(
41
- `Can\'t call ${methodName} before shell runtime is initiated`
41
+ `Can't call ${methodName} before shell runtime is initiated`
42
42
  );
43
43
  }
44
44