@mongosh/node-runtime-worker-thread 1.2.3 → 1.4.1

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.
Files changed (44) hide show
  1. package/AUTHORS +1 -0
  2. package/dist/child-process-evaluation-listener.d.ts +1 -1
  3. package/dist/child-process-evaluation-listener.js +51 -0
  4. package/dist/child-process-evaluation-listener.js.map +1 -0
  5. package/dist/child-process-mongosh-bus.js +25 -0
  6. package/dist/child-process-mongosh-bus.js.map +1 -0
  7. package/dist/child-process-proxy.js +1 -1
  8. package/dist/child-process-proxy.js.map +1 -0
  9. package/dist/index.d.ts +2 -1
  10. package/dist/index.js +1 -1
  11. package/dist/index.js.map +1 -0
  12. package/dist/lock.js +37 -0
  13. package/dist/lock.js.map +1 -0
  14. package/dist/rpc.js +143 -0
  15. package/dist/rpc.js.map +1 -0
  16. package/dist/serializer.d.ts +3 -0
  17. package/dist/serializer.js +106 -0
  18. package/dist/serializer.js.map +1 -0
  19. package/dist/spawn-child-from-source.js +68 -0
  20. package/dist/spawn-child-from-source.js.map +1 -0
  21. package/dist/src/child-process-evaluation-listener.d.ts +10 -0
  22. package/dist/src/child-process-mongosh-bus.d.ts +9 -0
  23. package/dist/src/child-process-proxy.d.ts +1 -0
  24. package/dist/src/index.d.ts +29 -0
  25. package/dist/src/lock.d.ts +10 -0
  26. package/dist/src/rpc.d.ts +28 -0
  27. package/dist/src/serializer.d.ts +13 -0
  28. package/dist/src/spawn-child-from-source.d.ts +4 -0
  29. package/dist/src/worker-runtime.d.ts +14 -0
  30. package/dist/worker-runtime.d.ts +3 -1
  31. package/dist/worker-runtime.js +101 -97
  32. package/dist/worker-runtime.js.map +1 -0
  33. package/package.json +10 -10
  34. package/src/child-process-evaluation-listener.ts +1 -1
  35. package/src/index.spec.ts +8 -8
  36. package/src/index.ts +4 -3
  37. package/src/lock.spec.ts +1 -1
  38. package/src/rpc.spec.ts +4 -4
  39. package/src/rpc.ts +2 -2
  40. package/src/serializer.spec.ts +51 -1
  41. package/src/serializer.ts +34 -0
  42. package/src/spawn-child-from-source.spec.ts +3 -3
  43. package/src/worker-runtime.spec.ts +6 -6
  44. package/src/worker-runtime.ts +6 -7
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worker-runtime.js","sourceRoot":"","sources":["../src/worker-runtime.ts"],"names":[],"mappings":"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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mongosh/node-runtime-worker-thread",
3
- "version": "1.2.3",
3
+ "version": "1.4.1",
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",
@@ -22,18 +22,18 @@
22
22
  "test-ci": "node ../../scripts/run-if-package-requested.js npm test",
23
23
  "lint": "eslint --report-unused-disable-directives \"./{src,test}/**/*.{js,ts,tsx}\"",
24
24
  "check": "npm run lint && depcheck",
25
- "webpack-build": "webpack --mode production",
26
- "webpack-build-dev": "webpack --mode development",
25
+ "webpack-build": "npm run compile-ts && webpack --mode production",
26
+ "webpack-build-dev": "npm run compile-ts && webpack --mode development",
27
27
  "compile-ts": "tsc -p tsconfig.json",
28
28
  "prepublish": "npm run webpack-build"
29
29
  },
30
30
  "devDependencies": {
31
- "@mongosh/browser-runtime-core": "1.2.3",
32
- "@mongosh/browser-runtime-electron": "1.2.3",
33
- "@mongosh/service-provider-core": "1.2.3",
34
- "@mongosh/service-provider-server": "1.2.3",
35
- "@mongosh/types": "1.2.3",
36
- "bson": "^4.6.1",
31
+ "@mongosh/browser-runtime-core": "1.4.1",
32
+ "@mongosh/browser-runtime-electron": "1.4.1",
33
+ "@mongosh/service-provider-core": "1.4.1",
34
+ "@mongosh/service-provider-server": "1.4.1",
35
+ "@mongosh/types": "1.4.1",
36
+ "bson": "^4.6.2",
37
37
  "mocha": "^7.1.2",
38
38
  "postmsg-rpc": "^2.4.0",
39
39
  "terser-webpack-plugin": "^4.2.3",
@@ -45,5 +45,5 @@
45
45
  "interruptor": "^1.0.1",
46
46
  "system-ca": "^1.0.2"
47
47
  },
48
- "gitHead": "b715268260871b62ac628cef3eb1009203a91264"
48
+ "gitHead": "4e88ce238c93af5f2eb5ad9f9e3a2ac5ef1eb2e0"
49
49
  }
@@ -4,7 +4,7 @@ import type { WorkerRuntime } from './index';
4
4
  import { RuntimeEvaluationListener } from '@mongosh/browser-runtime-core';
5
5
 
6
6
  export class ChildProcessEvaluationListener {
7
- exposedListener: Exposed<Required<Omit<RuntimeEvaluationListener, 'onLoad' | 'startMongocryptd'>>>;
7
+ exposedListener: Exposed<Required<Omit<RuntimeEvaluationListener, 'onLoad' | 'getCSFLELibraryOptions'>>>;
8
8
 
9
9
  constructor(workerRuntime: WorkerRuntime, childProcess: ChildProcess) {
10
10
  this.exposedListener = exposeAll(
package/src/index.spec.ts CHANGED
@@ -47,7 +47,7 @@ describe('WorkerRuntime', () => {
47
47
 
48
48
  try {
49
49
  await runtime.evaluate('1+1');
50
- } catch (e) {
50
+ } catch (e: any) {
51
51
  err = e;
52
52
  }
53
53
 
@@ -66,7 +66,7 @@ describe('WorkerRuntime', () => {
66
66
 
67
67
  try {
68
68
  await runtime.evaluate('1+1');
69
- } catch (e) {
69
+ } catch (e: any) {
70
70
  err = e;
71
71
  }
72
72
 
@@ -91,7 +91,7 @@ describe('WorkerRuntime', () => {
91
91
 
92
92
  try {
93
93
  await runtime.evaluate('throw new TypeError("Oh no, types!")');
94
- } catch (e) {
94
+ } catch (e: any) {
95
95
  err = e;
96
96
  }
97
97
 
@@ -189,7 +189,7 @@ describe('WorkerRuntime', () => {
189
189
  try {
190
190
  process.kill(pid, 0);
191
191
  return true;
192
- } catch (e) {
192
+ } catch (e: any) {
193
193
  return false;
194
194
  }
195
195
  }
@@ -223,7 +223,7 @@ describe('WorkerRuntime', () => {
223
223
  await runtime.terminate();
224
224
  })()
225
225
  ]);
226
- } catch (e) {
226
+ } catch (e: any) {
227
227
  err = e;
228
228
  }
229
229
  expect(err).to.be.instanceof(Error);
@@ -250,7 +250,7 @@ describe('WorkerRuntime', () => {
250
250
  await runtime.interrupt();
251
251
  })()
252
252
  ]);
253
- } catch (e) {
253
+ } catch (e: any) {
254
254
  err = e;
255
255
  }
256
256
 
@@ -275,7 +275,7 @@ describe('WorkerRuntime', () => {
275
275
  await runtime.interrupt();
276
276
  })()
277
277
  ]);
278
- } catch (e) {
278
+ } catch (e: any) {
279
279
  err = e;
280
280
  }
281
281
 
@@ -298,7 +298,7 @@ describe('WorkerRuntime', () => {
298
298
  await runtime.interrupt();
299
299
  })()
300
300
  ]);
301
- } catch (e) {
301
+ } catch (e: any) {
302
302
  // ignore
303
303
  }
304
304
 
package/src/index.ts CHANGED
@@ -2,7 +2,6 @@
2
2
  /* ^^^ we test the dist directly, so isntanbul can't calculate the coverage correctly */
3
3
 
4
4
  import { ChildProcess, spawn, SpawnOptionsWithoutStdio } from 'child_process';
5
- import type { DevtoolsConnectOptions } from '@mongosh/service-provider-server';
6
5
  import {
7
6
  Runtime,
8
7
  RuntimeEvaluationListener,
@@ -15,9 +14,11 @@ import { kill } from './spawn-child-from-source';
15
14
  import { Caller, createCaller, cancel } from './rpc';
16
15
  import { ChildProcessEvaluationListener } from './child-process-evaluation-listener';
17
16
  import type { WorkerRuntime as WorkerThreadWorkerRuntime } from './worker-runtime';
18
- import { deserializeEvaluationResult } from './serializer';
17
+ import { deserializeEvaluationResult, serializeConnectOptions } from './serializer';
19
18
  import { ChildProcessMongoshBus } from './child-process-mongosh-bus';
19
+ import type { CompassServiceProvider } from '@mongosh/service-provider-server';
20
20
 
21
+ type DevtoolsConnectOptions = Parameters<(typeof CompassServiceProvider)['connect']>[1];
21
22
  type ChildProcessRuntime = Caller<WorkerThreadWorkerRuntime>;
22
23
 
23
24
  function parseStderrToError(str: string): Error | null {
@@ -158,7 +159,7 @@ class WorkerRuntime implements Runtime {
158
159
  this.childProcess
159
160
  );
160
161
 
161
- await this.childProcessRuntime.init(uri, driverOptions, cliOptions);
162
+ await this.childProcessRuntime.init(uri, serializeConnectOptions(driverOptions), cliOptions);
162
163
  }
163
164
 
164
165
  async evaluate(code: string): Promise<RuntimeEvaluationResult> {
package/src/lock.spec.ts CHANGED
@@ -30,7 +30,7 @@ describe('Lock', () => {
30
30
  try {
31
31
  // eslint-disable-next-line @typescript-eslint/no-floating-promises
32
32
  lock.lock();
33
- } catch (e) {
33
+ } catch (e: any) {
34
34
  err = e;
35
35
  } finally {
36
36
  lock.unlock();
package/src/rpc.spec.ts CHANGED
@@ -115,7 +115,7 @@ describe('rpc', () => {
115
115
  try {
116
116
  // eslint-disable-next-line @typescript-eslint/await-thenable
117
117
  await caller.throws();
118
- } catch (e) {
118
+ } catch (e: any) {
119
119
  err = e;
120
120
  }
121
121
 
@@ -144,7 +144,7 @@ describe('rpc', () => {
144
144
 
145
145
  try {
146
146
  await caller.callMe((a: number, b: number) => a + b);
147
- } catch (e) {
147
+ } catch (e: any) {
148
148
  err = e;
149
149
  }
150
150
 
@@ -171,7 +171,7 @@ describe('rpc', () => {
171
171
 
172
172
  try {
173
173
  await caller.returnsFunction();
174
- } catch (e) {
174
+ } catch (e: any) {
175
175
  err = e;
176
176
  }
177
177
 
@@ -217,7 +217,7 @@ describe('rpc', () => {
217
217
  caller[cancel]();
218
218
  })()
219
219
  ]);
220
- } catch (e) {
220
+ } catch (e: any) {
221
221
  err = e;
222
222
  }
223
223
  expect(err).to.be.instanceof(Error);
package/src/rpc.ts CHANGED
@@ -98,7 +98,7 @@ function getRPCOptions(messageBus: RPCMessageBus): PostmsgRpcOptions {
98
98
  // that was executing the method.
99
99
  try {
100
100
  data.res = serialize(data.res);
101
- } catch (e) {
101
+ } catch (e: any) {
102
102
  data.res = serialize({
103
103
  type: RPCMessageTypes.Error,
104
104
  payload: serializeError(e)
@@ -141,7 +141,7 @@ export function exposeAll<O>(obj: O, messageBus: RPCMessageBus): Exposed<O> {
141
141
  async(...args: unknown[]) => {
142
142
  try {
143
143
  return { type: RPCMessageTypes.Message, payload: await val(...args) };
144
- } catch (e) {
144
+ } catch (e: any) {
145
145
  // If server (whatever is executing the exposed method) throws during
146
146
  // the execution, we want to propagate error to the client (whatever
147
147
  // issued the call) and re-throw there. We will do this with a special
@@ -1,10 +1,14 @@
1
+ import { DevtoolsConnectOptions } from '@mongosh/service-provider-server/lib/cli-service-provider';
1
2
  import { expect } from 'chai';
3
+ import { UUID } from 'bson';
2
4
  import {
3
5
  serializeError,
4
6
  deserializeError,
5
7
  serializeEvaluationResult,
6
8
  deserializeEvaluationResult,
7
- SerializedResultTypes
9
+ SerializedResultTypes,
10
+ serializeConnectOptions,
11
+ deserializeConnectOptions
8
12
  } from './serializer';
9
13
 
10
14
  describe('serializer', () => {
@@ -135,4 +139,50 @@ describe('serializer', () => {
135
139
  expect(deserialized).to.have.property('printable', 'Hello');
136
140
  });
137
141
  });
142
+
143
+ describe('connection options', () => {
144
+ it('should serialize and deserialize connection options', () => {
145
+ const options: DevtoolsConnectOptions = {
146
+ autoEncryption: {
147
+ schemaMap: {
148
+ 'hr.employees': {
149
+ bsonType: 'object',
150
+ properties: {
151
+ taxid: {
152
+ encrypt: {
153
+ keyId: [ new UUID('a21ddc6a-8806-4384-9fdf-8ba02a767b5f').toBinary() ],
154
+ bsonType: 'string',
155
+ algorithm: 'AEAD_AES_256_CBC_HMAC_SHA_512-Random'
156
+ }
157
+ }
158
+ }
159
+ }
160
+ }
161
+ }
162
+ };
163
+
164
+ const serialized = serializeConnectOptions(options);
165
+
166
+ expect(serialized).to.deep.equal({
167
+ autoEncryption: {
168
+ schemaMap: {
169
+ 'hr.employees': {
170
+ bsonType: 'object',
171
+ properties: {
172
+ taxid: {
173
+ encrypt: {
174
+ keyId: [ { $binary: { base64: 'oh3caogGQ4Sf34ugKnZ7Xw==', subType: '04' } } ],
175
+ bsonType: 'string',
176
+ algorithm: 'AEAD_AES_256_CBC_HMAC_SHA_512-Random'
177
+ }
178
+ }
179
+ }
180
+ }
181
+ }
182
+ }
183
+ });
184
+
185
+ expect(deserializeConnectOptions(serialized)).to.deep.equal(options);
186
+ });
187
+ });
138
188
  });
package/src/serializer.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { inspect } from 'util';
2
2
  import { EJSON } from 'bson';
3
3
  import { RuntimeEvaluationResult } from '@mongosh/browser-runtime-core';
4
+ import type { DevtoolsConnectOptions } from '@mongosh/service-provider-server/lib/cli-service-provider';
4
5
 
5
6
  function isPrimitive(
6
7
  val: any
@@ -110,3 +111,36 @@ export function deserializeEvaluationResult({
110
111
 
111
112
  return { type, printable, source };
112
113
  }
114
+
115
+ const autoEncryptionBSONOptions = [
116
+ 'schemaMap',
117
+ // Note: This is an educated guess for what the name of this option will be.
118
+ // This may need to be adjusted later.
119
+ 'encryptedFieldConfigMap'
120
+ ] as const;
121
+
122
+ export function serializeConnectOptions(options: Readonly<DevtoolsConnectOptions> = {}): DevtoolsConnectOptions {
123
+ const serializedOptions: any = { ...options };
124
+ for (const autoEncryptionOption of autoEncryptionBSONOptions) {
125
+ if (serializedOptions.autoEncryption?.[autoEncryptionOption]) {
126
+ serializedOptions.autoEncryption = {
127
+ ...serializedOptions.autoEncryption,
128
+ [autoEncryptionOption]: EJSON.serialize(serializedOptions.autoEncryption[autoEncryptionOption])
129
+ };
130
+ }
131
+ }
132
+ return serializedOptions;
133
+ }
134
+
135
+ export function deserializeConnectOptions(options: Readonly<DevtoolsConnectOptions>): DevtoolsConnectOptions {
136
+ const deserializedOptions: any = { ...options };
137
+ for (const autoEncryptionOption of autoEncryptionBSONOptions) {
138
+ if (deserializedOptions.autoEncryption?.[autoEncryptionOption]) {
139
+ deserializedOptions.autoEncryption = {
140
+ ...deserializedOptions.autoEncryption,
141
+ [autoEncryptionOption]: EJSON.deserialize(deserializedOptions.autoEncryption[autoEncryptionOption])
142
+ };
143
+ }
144
+ }
145
+ return deserializedOptions;
146
+ }
@@ -23,7 +23,7 @@ describe('spawnChildFromSource', () => {
23
23
  // @ts-expect-error
24
24
  stdio: 'ignore'
25
25
  });
26
- } catch (e) {
26
+ } catch (e: any) {
27
27
  err = e;
28
28
  }
29
29
 
@@ -58,7 +58,7 @@ describe('spawnChildFromSource', () => {
58
58
  'ignore',
59
59
  'ignore'
60
60
  );
61
- } catch (e) {
61
+ } catch (e: any) {
62
62
  err = e;
63
63
  }
64
64
 
@@ -77,7 +77,7 @@ describe('spawnChildFromSource', () => {
77
77
  {},
78
78
  10
79
79
  );
80
- } catch (e) {
80
+ } catch (e: any) {
81
81
  err = e;
82
82
  }
83
83
 
@@ -82,7 +82,7 @@ describe('worker', () => {
82
82
 
83
83
  try {
84
84
  await evaluate('1 + 1');
85
- } catch (e) {
85
+ } catch (e: any) {
86
86
  err = e;
87
87
  }
88
88
 
@@ -384,7 +384,7 @@ describe('worker', () => {
384
384
  let err: Error;
385
385
  try {
386
386
  await evaluate('throw new TypeError("Oh no, types!")');
387
- } catch (e) {
387
+ } catch (e: any) {
388
388
  err = e;
389
389
  }
390
390
 
@@ -404,7 +404,7 @@ describe('worker', () => {
404
404
  let err: Error;
405
405
  try {
406
406
  await evaluate('throw Object.assign(new TypeError("Oh no, types!"), { errInfo: { message: "wrong type :S" } })');
407
- } catch (e) {
407
+ } catch (e: any) {
408
408
  err = e;
409
409
  }
410
410
 
@@ -440,7 +440,7 @@ describe('worker', () => {
440
440
  evaluate('sleep(50); 1+1'),
441
441
  evaluate('sleep(50); 1+1')
442
442
  ]);
443
- } catch (e) {
443
+ } catch (e: any) {
444
444
  err = e;
445
445
  }
446
446
 
@@ -653,7 +653,7 @@ describe('worker', () => {
653
653
  interrupt(handle);
654
654
  })()
655
655
  ]);
656
- } catch (e) {
656
+ } catch (e: any) {
657
657
  err = e;
658
658
  }
659
659
 
@@ -681,7 +681,7 @@ describe('worker', () => {
681
681
  await interrupt();
682
682
  })()
683
683
  ]);
684
- } catch (e) {
684
+ } catch (e: any) {
685
685
  err = e;
686
686
  }
687
687
 
@@ -8,19 +8,18 @@ import {
8
8
  RuntimeEvaluationResult
9
9
  } from '@mongosh/browser-runtime-core';
10
10
  import { ElectronRuntime } from '@mongosh/browser-runtime-electron';
11
- import type {
12
- ServiceProvider
13
- } from '@mongosh/service-provider-core';
11
+ import type { ServiceProvider } from '@mongosh/service-provider-core';
14
12
  import {
15
- CompassServiceProvider,
16
- DevtoolsConnectOptions
13
+ CompassServiceProvider
17
14
  } from '@mongosh/service-provider-server';
18
15
  import { exposeAll, createCaller } from './rpc';
19
- import { serializeEvaluationResult } from './serializer';
16
+ import { serializeEvaluationResult, deserializeConnectOptions } from './serializer';
20
17
  import type { MongoshBus } from '@mongosh/types';
21
18
  import { Lock, UNLOCKED } from './lock';
22
19
  import { runInterruptible, InterruptHandle } from 'interruptor';
23
20
 
21
+ type DevtoolsConnectOptions = Parameters<(typeof CompassServiceProvider)['connect']>[1];
22
+
24
23
  if (!parentPort || isMainThread) {
25
24
  throw new Error('Worker runtime can be used only in a worker thread');
26
25
  }
@@ -98,7 +97,7 @@ const workerRuntime: WorkerRuntime = {
98
97
  // will have to do for now.
99
98
  provider = await (CompassServiceProvider as any).connect(
100
99
  uri,
101
- driverOptions,
100
+ deserializeConnectOptions(driverOptions),
102
101
  cliOptions,
103
102
  messageBus
104
103
  );