@mongosh/node-runtime-worker-thread 3.3.30 → 3.3.33

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mongosh/node-runtime-worker-thread",
3
- "version": "3.3.30",
3
+ "version": "3.3.33",
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",
@@ -17,7 +17,7 @@
17
17
  "node": ">=14.15.1"
18
18
  },
19
19
  "scripts": {
20
- "test": "mocha -r \"../../scripts/import-expansions.js\" -r \"./tests/register-worker.js \" --timeout 15000 -r ts-node/register --reporter \"../../configs/mocha-config-mongosh/reporter.ts\" \"./src/**/*.spec.ts\"",
20
+ "test": "mocha",
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
23
  "test-coverage": "nyc --no-clean --cwd ../.. --reporter=none npm run test",
@@ -40,11 +40,11 @@
40
40
  "@mongodb-js/prettier-config-devtools": "^1.0.1",
41
41
  "@mongodb-js/sbom-tools": "^0.8.1",
42
42
  "@mongodb-js/tsconfig-mongosh": "^1.0.0",
43
- "@mongosh/browser-runtime-core": "^3.26.2",
44
- "@mongosh/browser-runtime-electron": "^3.26.2",
45
- "@mongosh/service-provider-core": "3.6.3",
46
- "@mongosh/service-provider-node-driver": "^3.17.5",
47
- "@mongosh/types": "^3.14.0",
43
+ "@mongosh/browser-runtime-core": "^3.29.0",
44
+ "@mongosh/browser-runtime-electron": "^3.29.0",
45
+ "@mongosh/service-provider-core": "3.7.0",
46
+ "@mongosh/service-provider-node-driver": "^3.18.0",
47
+ "@mongosh/types": "^3.14.1",
48
48
  "bson": "^6.10.4",
49
49
  "depcheck": "^1.4.7",
50
50
  "eslint": "^7.25.0",
@@ -58,5 +58,5 @@
58
58
  "system-ca": "^2.0.1",
59
59
  "web-worker": "^1.3.0"
60
60
  },
61
- "gitHead": "8e8f9d1a0486078c4ca75fc7a81535eba535f535"
61
+ "gitHead": "d2069810a846a535c51c88929224a57e49960778"
62
62
  }
package/src/index.spec.ts CHANGED
@@ -1,4 +1,5 @@
1
- import chai, { expect } from 'chai';
1
+ import * as chai from 'chai';
2
+ import { expect } from 'chai';
2
3
  import sinon from 'sinon';
3
4
  import sinonChai from 'sinon-chai';
4
5
  import type { MongoshBus } from '@mongosh/types';
package/src/rpc.ts CHANGED
@@ -8,25 +8,18 @@ export type RPCMessageBus = {
8
8
  removeEventListener: Function;
9
9
  };
10
10
 
11
- enum RPCMessageTypes {
12
- Message,
13
- Error,
14
- }
15
-
16
11
  type RPCMessage = {
17
- type: RPCMessageTypes.Message;
12
+ type: 'Message';
18
13
  payload: string;
19
14
  };
20
15
 
21
16
  type RPCError = {
22
- type: RPCMessageTypes.Error;
17
+ type: 'Error';
23
18
  payload: Error;
24
19
  };
25
20
 
26
21
  function isRPCError(data: any): data is RPCError {
27
- return (
28
- data && typeof data === 'object' && data.type === RPCMessageTypes.Error
29
- );
22
+ return data && typeof data === 'object' && data.type === 'Error';
30
23
  }
31
24
 
32
25
  function getRPCOptions(messageBus: RPCMessageBus): PostmsgRpcOptions {
@@ -59,13 +52,13 @@ export function exposeAll<O extends object>(
59
52
  key,
60
53
  async (...args: unknown[]) => {
61
54
  try {
62
- return { type: RPCMessageTypes.Message, payload: await val(...args) };
55
+ return { type: 'Message', payload: await val(...args) };
63
56
  } catch (e: any) {
64
57
  // If server (whatever is executing the exposed method) throws during
65
58
  // the execution, we want to propagate error to the client (whatever
66
59
  // issued the call) and re-throw there. We will do this with a special
67
60
  // return type.
68
- return { type: RPCMessageTypes.Error, payload: serializeError(e) };
61
+ return { type: 'Error', payload: serializeError(e) };
69
62
  }
70
63
  },
71
64
  getRPCOptions(messageBus)
@@ -6,7 +6,6 @@ import {
6
6
  deserializeError,
7
7
  serializeEvaluationResult,
8
8
  deserializeEvaluationResult,
9
- SerializedResultTypes,
10
9
  serializeConnectOptions,
11
10
  deserializeConnectOptions,
12
11
  } from './serializer';
@@ -50,10 +49,7 @@ describe('serializer', function () {
50
49
  printable: new SyntaxError('Ooops!'),
51
50
  });
52
51
 
53
- expect(serialized).to.have.property(
54
- 'type',
55
- SerializedResultTypes.SerializedErrorResult
56
- );
52
+ expect(serialized).to.have.property('type', 'SerializedErrorResult');
57
53
  expect(serialized).to.have.property('printable').not.instanceof(Error);
58
54
  expect(serialized).to.have.nested.property(
59
55
  'printable.name',
@@ -68,10 +64,7 @@ describe('serializer', function () {
68
64
  printable: function abc() {},
69
65
  });
70
66
 
71
- expect(serialized).to.have.property(
72
- 'type',
73
- SerializedResultTypes.InspectResult
74
- );
67
+ expect(serialized).to.have.property('type', 'InspectResult');
75
68
  expect(serialized).to.have.property('printable', '[Function: abc]');
76
69
  });
77
70
 
@@ -81,10 +74,7 @@ describe('serializer', function () {
81
74
  printable: { foo: 'bar' },
82
75
  });
83
76
 
84
- expect(serialized).to.have.property(
85
- 'type',
86
- SerializedResultTypes.SerializedShellApiResult
87
- );
77
+ expect(serialized).to.have.property('type', 'SerializedShellApiResult');
88
78
  expect(serialized).to.have.nested.property(
89
79
  'printable.origType',
90
80
  'TotallyRealShellApiType'
@@ -100,7 +90,7 @@ describe('serializer', function () {
100
90
  describe('deserializeEvaluationResult', function () {
101
91
  it('should deserialize SerializedErrorResult', function () {
102
92
  const deserialized = deserializeEvaluationResult({
103
- type: SerializedResultTypes.SerializedErrorResult,
93
+ type: 'SerializedErrorResult',
104
94
  printable: { name: 'TypeError', message: 'Uh-oh' },
105
95
  });
106
96
 
@@ -117,7 +107,7 @@ describe('serializer', function () {
117
107
 
118
108
  it('should deserialize SerializedShellApiResult', function () {
119
109
  const deserialized = deserializeEvaluationResult({
120
- type: SerializedResultTypes.SerializedShellApiResult,
110
+ type: 'SerializedShellApiResult',
121
111
  printable: {
122
112
  origType: 'ShellApiResult',
123
113
  serializedValue: { foo: 'bar' },
package/src/serializer.ts CHANGED
@@ -44,11 +44,10 @@ export function deserializeError(err: any): Error {
44
44
  return Object.assign(new Error(), err);
45
45
  }
46
46
 
47
- export enum SerializedResultTypes {
48
- SerializedErrorResult = 'SerializedErrorResult',
49
- InspectResult = 'InspectResult',
50
- SerializedShellApiResult = 'SerializedShellApiResult',
51
- }
47
+ export type SerializedResultTypes =
48
+ | 'SerializedErrorResult'
49
+ | 'InspectResult'
50
+ | 'SerializedShellApiResult';
52
51
 
53
52
  export function serializeEvaluationResult({
54
53
  type,
@@ -63,7 +62,7 @@ export function serializeEvaluationResult({
63
62
  // Errors are serialized as some error metadata can be lost without this
64
63
  if (isError(printable)) {
65
64
  return {
66
- type: SerializedResultTypes.SerializedErrorResult,
65
+ type: 'SerializedErrorResult',
67
66
  printable: serializeError(printable),
68
67
  source,
69
68
  };
@@ -77,7 +76,7 @@ export function serializeEvaluationResult({
77
76
  // before passing to the main thread
78
77
  if (type === null) {
79
78
  return {
80
- type: SerializedResultTypes.InspectResult,
79
+ type: 'InspectResult',
81
80
  printable: inspect(printable),
82
81
  source,
83
82
  };
@@ -87,7 +86,7 @@ export function serializeEvaluationResult({
87
86
  // to preserve as much information as possible, including serializing the
88
87
  // printable value to EJSON as its a common thing to be returned by shell-api
89
88
  return {
90
- type: SerializedResultTypes.SerializedShellApiResult,
89
+ type: 'SerializedShellApiResult',
91
90
  printable: {
92
91
  origType: type,
93
92
  serializedValue: EJSON.serialize(printable),
@@ -100,11 +99,11 @@ export function deserializeEvaluationResult({
100
99
  printable,
101
100
  source,
102
101
  }: RuntimeEvaluationResult): RuntimeEvaluationResult {
103
- if (type === SerializedResultTypes.SerializedErrorResult) {
102
+ if (type === 'SerializedErrorResult') {
104
103
  return { type, printable: deserializeError(printable), source };
105
104
  }
106
105
 
107
- if (type === SerializedResultTypes.SerializedShellApiResult) {
106
+ if (type === 'SerializedShellApiResult') {
108
107
  return {
109
108
  type: printable.origType,
110
109
  printable: EJSON.deserialize(printable.serializedValue),
@@ -1,7 +1,8 @@
1
1
  import path from 'path';
2
2
  import { once } from 'events';
3
3
  import Worker from 'web-worker';
4
- import chai, { expect } from 'chai';
4
+ import * as chai from 'chai';
5
+ import { expect } from 'chai';
5
6
  import sinonChai from 'sinon-chai';
6
7
  import sinon from 'sinon';
7
8
  import { EJSON, ObjectId } from 'bson';
package/webpack.config.js CHANGED
@@ -20,11 +20,17 @@ const config = {
20
20
  plugins: [webpackDependenciesPlugin],
21
21
  externals: {
22
22
  'mongodb-client-encryption': 'commonjs2 mongodb-client-encryption',
23
+ 'mongodb-client-encryption/package.json':
24
+ 'commonjs2 mongodb-client-encryption/package.json',
23
25
  kerberos: 'commonjs2 kerberos',
26
+ 'kerberos/package.json': 'commonjs2 kerberos/package.json',
24
27
  snappy: 'commonjs2 snappy',
25
28
  interruptor: 'commonjs2 interruptor',
26
29
  'os-dns-native': 'commonjs2 os-dns-native',
27
30
  'system-ca': 'commonjs2 system-ca',
31
+ // TODO(MONGOSH-3055): This is a temporary workaround.
32
+ // @aws-sdk/client-sts is an optional peer dependency of @aws-sdk/credential-providers
33
+ '@aws-sdk/client-sts': 'commonjs2 @aws-sdk/client-sts',
28
34
  },
29
35
  };
30
36