@midwayjs/mock 4.0.0-beta.7 → 4.0.0-beta.8

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,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createHttpRequest = void 0;
3
+ exports.createHttpRequest = createHttpRequest;
4
4
  const request = require("supertest");
5
5
  function createHttpRequest(app) {
6
6
  if (app.callback2) {
@@ -13,5 +13,4 @@ function createHttpRequest(app) {
13
13
  return request(app);
14
14
  }
15
15
  }
16
- exports.createHttpRequest = createHttpRequest;
17
16
  //# sourceMappingURL=http.js.map
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createKafkaProducer = void 0;
3
+ exports.createKafkaProducer = createKafkaProducer;
4
4
  const connect = async () => ({
5
5
  producer: () => { },
6
6
  cousumer: () => { },
@@ -15,5 +15,4 @@ async function createKafkaProducer(options = {
15
15
  const kafka = new Kafka(options.kafkaConfig);
16
16
  return kafka.producer(options.producerConfig);
17
17
  }
18
- exports.createKafkaProducer = createKafkaProducer;
19
18
  //# sourceMappingURL=kafka.js.map
@@ -1,5 +1,3 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
1
  import type { Channel, Options } from 'amqplib';
4
2
  declare class ChannelManager {
5
3
  private connection;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createRabbitMQProducer = void 0;
3
+ exports.createRabbitMQProducer = createRabbitMQProducer;
4
4
  const queues = {};
5
5
  const exchanges = {};
6
6
  const eventListeners = [];
@@ -282,8 +282,10 @@ const connect = async () => ({
282
282
  close: () => { },
283
283
  });
284
284
  class ChannelManager {
285
+ connection;
286
+ channel;
287
+ channelList = [];
285
288
  constructor(connection) {
286
- this.channelList = [];
287
289
  this.connection = connection;
288
290
  }
289
291
  async assertQueue(queue, options) {
@@ -344,5 +346,4 @@ async function createRabbitMQProducer(queueName, options = {
344
346
  return channelManager;
345
347
  }
346
348
  }
347
- exports.createRabbitMQProducer = createRabbitMQProducer;
348
349
  //# sourceMappingURL=rabbitMQ.js.map
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import type { ManagerOptions, SocketOptions } from 'socket.io-client';
3
2
  export interface MidwaySocketIOClientOptions extends Partial<ManagerOptions & SocketOptions> {
4
3
  url?: string;
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createSocketIOClient = exports.SocketIOWrapperClient = void 0;
3
+ exports.SocketIOWrapperClient = void 0;
4
+ exports.createSocketIOClient = createSocketIOClient;
4
5
  class SocketIOWrapperClient {
6
+ socket;
5
7
  constructor(socket) {
6
8
  this.socket = socket;
7
9
  }
@@ -57,5 +59,4 @@ async function createSocketIOClient(opts) {
57
59
  await client.connect();
58
60
  return client;
59
61
  }
60
- exports.createSocketIOClient = createSocketIOClient;
61
62
  //# sourceMappingURL=socketio.js.map
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import { EventEmitter } from 'events';
3
2
  export interface SSEClientOptions {
4
3
  headers?: Record<string, string>;
@@ -1,16 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createSSEClient = exports.SSEClient = void 0;
3
+ exports.SSEClient = void 0;
4
+ exports.createSSEClient = createSSEClient;
4
5
  const http = require("http");
5
6
  const https = require("https");
6
7
  const events_1 = require("events");
7
8
  class SSEClient extends events_1.EventEmitter {
9
+ url;
10
+ options;
11
+ request;
12
+ reconnectAttempts = 0;
13
+ shouldReconnect = true;
14
+ reconnectTimer;
8
15
  constructor(url, options = {}) {
9
16
  super();
10
17
  this.url = url;
11
18
  this.options = options;
12
- this.reconnectAttempts = 0;
13
- this.shouldReconnect = true;
14
19
  this.options = {
15
20
  timeout: 30000,
16
21
  reconnectInterval: 3000,
@@ -136,5 +141,4 @@ exports.SSEClient = SSEClient;
136
141
  function createSSEClient(url, options) {
137
142
  return new SSEClient(url, options);
138
143
  }
139
- exports.createSSEClient = createSSEClient;
140
144
  //# sourceMappingURL=sse.js.map
@@ -1,5 +1,3 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
1
  import * as WebSocket from 'ws';
4
2
  import * as http from 'http';
5
3
  import * as url from 'url';
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createWebSocketClient = void 0;
3
+ exports.createWebSocketClient = createWebSocketClient;
4
4
  async function createWebSocketClient(address, options) {
5
5
  const WebSocket = require('ws');
6
6
  const client = new WebSocket(address, options);
@@ -10,5 +10,4 @@ async function createWebSocketClient(address, options) {
10
10
  });
11
11
  });
12
12
  }
13
- exports.createWebSocketClient = createWebSocketClient;
14
13
  //# sourceMappingURL=ws.client.js.map
package/dist/creator.js CHANGED
@@ -1,6 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createBootstrap = exports.createLightApp = exports.createFunctionApp = exports.close = exports.createApp = exports.create = void 0;
3
+ exports.create = create;
4
+ exports.createApp = createApp;
5
+ exports.close = close;
6
+ exports.createFunctionApp = createFunctionApp;
7
+ exports.createLightApp = createLightApp;
8
+ exports.createBootstrap = createBootstrap;
4
9
  const core_1 = require("@midwayjs/core");
5
10
  const path_1 = require("path");
6
11
  const logger_1 = require("@midwayjs/logger");
@@ -200,12 +205,10 @@ async function create(appDir, options = {}) {
200
205
  throw err;
201
206
  }
202
207
  }
203
- exports.create = create;
204
208
  async function createApp(baseDir, options) {
205
209
  const framework = await create(baseDir, options);
206
210
  return framework.getApplication();
207
211
  }
208
- exports.createApp = createApp;
209
212
  async function close(app, options) {
210
213
  if (!app)
211
214
  return;
@@ -237,7 +240,6 @@ async function close(app, options) {
237
240
  }
238
241
  }
239
242
  }
240
- exports.close = close;
241
243
  async function createFunctionApp(baseDir, options = {}, customFrameworkModule) {
242
244
  process.env.MIDWAY_TS_MODE = process.env.MIDWAY_TS_MODE ?? 'true';
243
245
  if (typeof baseDir === 'object') {
@@ -450,7 +452,6 @@ async function createFunctionApp(baseDir, options = {}, customFrameworkModule) {
450
452
  return appManager.getApplication('serverless-app');
451
453
  }
452
454
  }
453
- exports.createFunctionApp = createFunctionApp;
454
455
  /**
455
456
  * 一个全量的空框架
456
457
  */
@@ -468,6 +469,7 @@ class LightFramework extends core_1.BaseFramework {
468
469
  }
469
470
  }
470
471
  class BootstrapAppStarter {
472
+ options;
471
473
  constructor(options) {
472
474
  this.options = options;
473
475
  }
@@ -543,7 +545,6 @@ async function createLightApp(baseDirOrOptions, options = {}) {
543
545
  return frameworkService.getMainApp();
544
546
  }
545
547
  }
546
- exports.createLightApp = createLightApp;
547
548
  async function createBootstrap(entryFile, options = {}) {
548
549
  const cwd = process.cwd();
549
550
  if (!options.bootstrapMode) {
@@ -567,5 +568,4 @@ async function createBootstrap(entryFile, options = {}) {
567
568
  return new BootstrapAppStarter(options);
568
569
  }
569
570
  }
570
- exports.createBootstrap = createBootstrap;
571
571
  //# sourceMappingURL=creator.js.map
package/dist/legacy.js CHANGED
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createLegacyLightApp = exports.createLegacyFunctionApp = exports.createLegacyApp = void 0;
3
+ exports.createLegacyApp = createLegacyApp;
4
+ exports.createLegacyFunctionApp = createLegacyFunctionApp;
5
+ exports.createLegacyLightApp = createLegacyLightApp;
4
6
  const creator_1 = require("./creator");
5
7
  const core_1 = require("@midwayjs/core");
6
8
  const functional_1 = require("@midwayjs/core/functional");
@@ -18,7 +20,6 @@ async function createLegacyApp(...args) {
18
20
  ];
19
21
  return (0, creator_1.createApp)(appDir, options);
20
22
  }
21
- exports.createLegacyApp = createLegacyApp;
22
23
  async function createLegacyFunctionApp(...args) {
23
24
  const appDir = typeof args[0] === 'string' ? args[0] : (args[0] ?? {}).appDir;
24
25
  const options = (typeof args[0] === 'string' ? args[1] : args[0]) ?? {};
@@ -33,7 +34,6 @@ async function createLegacyFunctionApp(...args) {
33
34
  ];
34
35
  return (0, creator_1.createFunctionApp)(appDir, options);
35
36
  }
36
- exports.createLegacyFunctionApp = createLegacyFunctionApp;
37
37
  async function createLegacyLightApp(...args) {
38
38
  const appDir = typeof args[0] === 'string' ? args[0] : (args[0] ?? {}).appDir;
39
39
  const options = (typeof args[0] === 'string' ? args[1] : args[0]) ?? {};
@@ -48,5 +48,4 @@ async function createLegacyLightApp(...args) {
48
48
  ];
49
49
  return (0, creator_1.createLightApp)(appDir, options);
50
50
  }
51
- exports.createLegacyLightApp = createLegacyLightApp;
52
51
  //# sourceMappingURL=legacy.js.map
package/dist/mock.js CHANGED
@@ -1,6 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mockContext = exports.restoreMocks = exports.restoreAllMocks = exports.mockProperty = exports.mockClassProperty = exports.mockHeader = exports.mockSession = void 0;
3
+ exports.mockSession = mockSession;
4
+ exports.mockHeader = mockHeader;
5
+ exports.mockClassProperty = mockClassProperty;
6
+ exports.mockProperty = mockProperty;
7
+ exports.restoreAllMocks = restoreAllMocks;
8
+ exports.restoreMocks = restoreMocks;
9
+ exports.mockContext = mockContext;
4
10
  const core_1 = require("@midwayjs/core");
5
11
  function getMockService(app) {
6
12
  if (!app) {
@@ -28,14 +34,12 @@ function mockSession(app, key, value, group = 'default') {
28
34
  ctx.session[key] = value;
29
35
  }, undefined, group);
30
36
  }
31
- exports.mockSession = mockSession;
32
37
  function mockHeader(app, headerKey, headerValue, group = 'default') {
33
38
  const mockService = getMockService(app);
34
39
  mockService.mockContext(app, (ctx) => {
35
40
  ctx.headers[headerKey] = headerValue;
36
41
  }, undefined, group);
37
42
  }
38
- exports.mockHeader = mockHeader;
39
43
  function mockClassProperty(clzz, propertyName, value, group = 'default') {
40
44
  const mockService = getMockService();
41
45
  if (!mockService) {
@@ -45,7 +49,6 @@ function mockClassProperty(clzz, propertyName, value, group = 'default') {
45
49
  return mockService.mockClassProperty(clzz, propertyName, value, group);
46
50
  }
47
51
  }
48
- exports.mockClassProperty = mockClassProperty;
49
52
  function mockProperty(obj, key, value, group = 'default') {
50
53
  const mockService = getMockService();
51
54
  if (!mockService) {
@@ -55,7 +58,6 @@ function mockProperty(obj, key, value, group = 'default') {
55
58
  return mockService.mockProperty(obj, key, value, group);
56
59
  }
57
60
  }
58
- exports.mockProperty = mockProperty;
59
61
  function restoreAllMocks() {
60
62
  const mockService = getMockService();
61
63
  if (mockService) {
@@ -65,17 +67,14 @@ function restoreAllMocks() {
65
67
  core_1.MidwayMockService.prepareMocks = [];
66
68
  }
67
69
  }
68
- exports.restoreAllMocks = restoreAllMocks;
69
70
  function restoreMocks(group = 'default') {
70
71
  const mockService = getMockService();
71
72
  if (mockService) {
72
73
  mockService.restore(group);
73
74
  }
74
75
  }
75
- exports.restoreMocks = restoreMocks;
76
76
  function mockContext(app, key, value, group = 'default') {
77
77
  const mockService = getMockService(app);
78
78
  mockService.mockContext(app, key, value, group);
79
79
  }
80
- exports.mockContext = mockContext;
81
80
  //# sourceMappingURL=mock.js.map
package/dist/utils.js CHANGED
@@ -6,7 +6,13 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
6
6
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7
7
  };
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.processArgsParser = exports.mergeGlobalConfig = exports.removeFile = exports.transformFrameworkToConfiguration = exports.findFirstExistModule = exports.isWin32 = exports.isTestEnvironment = void 0;
9
+ exports.isTestEnvironment = isTestEnvironment;
10
+ exports.isWin32 = isWin32;
11
+ exports.findFirstExistModule = findFirstExistModule;
12
+ exports.transformFrameworkToConfiguration = transformFrameworkToConfiguration;
13
+ exports.removeFile = removeFile;
14
+ exports.mergeGlobalConfig = mergeGlobalConfig;
15
+ exports.processArgsParser = processArgsParser;
10
16
  const core_1 = require("@midwayjs/core");
11
17
  const os = require("os");
12
18
  const assert = require("assert");
@@ -17,11 +23,9 @@ function isTestEnvironment() {
17
23
  testEnv.includes(process.env.EGG_SERVER_ENV) ||
18
24
  testEnv.includes(process.env.NODE_ENV));
19
25
  }
20
- exports.isTestEnvironment = isTestEnvironment;
21
26
  function isWin32() {
22
27
  return os.platform() === 'win32';
23
28
  }
24
- exports.isWin32 = isWin32;
25
29
  function findFirstExistModule(moduleList) {
26
30
  for (const name of moduleList) {
27
31
  if (!name)
@@ -34,7 +38,6 @@ function findFirstExistModule(moduleList) {
34
38
  }
35
39
  }
36
40
  }
37
- exports.findFirstExistModule = findFirstExistModule;
38
41
  /**
39
42
  * transform a framework component or framework module to configuration class
40
43
  * @param Framework
@@ -75,7 +78,6 @@ async function transformFrameworkToConfiguration(Framework, loadMode) {
75
78
  Framework,
76
79
  };
77
80
  }
78
- exports.transformFrameworkToConfiguration = transformFrameworkToConfiguration;
79
81
  async function removeFile(file) {
80
82
  try {
81
83
  await fs.promises.access(file, fs.constants.W_OK);
@@ -85,7 +87,6 @@ async function removeFile(file) {
85
87
  // ignore
86
88
  }
87
89
  }
88
- exports.removeFile = removeFile;
89
90
  function mergeGlobalConfig(globalConfig, newConfigObject) {
90
91
  if (globalConfig) {
91
92
  if (Array.isArray(globalConfig)) {
@@ -109,7 +110,6 @@ function mergeGlobalConfig(globalConfig, newConfigObject) {
109
110
  }
110
111
  return globalConfig;
111
112
  }
112
- exports.mergeGlobalConfig = mergeGlobalConfig;
113
113
  /**
114
114
  * 解析命令行参数的函数。
115
115
  * 它接受一个字符串数组作为输入,然后解析这个数组,
@@ -139,5 +139,4 @@ function processArgsParser(argv) {
139
139
  });
140
140
  return result;
141
141
  }
142
- exports.processArgsParser = processArgsParser;
143
142
  //# sourceMappingURL=utils.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midwayjs/mock",
3
- "version": "4.0.0-beta.7",
3
+ "version": "4.0.0-beta.8",
4
4
  "description": "create your test app from midway framework",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -29,7 +29,7 @@
29
29
  },
30
30
  "license": "MIT",
31
31
  "devDependencies": {
32
- "@midwayjs/core": "^4.0.0-beta.7",
32
+ "@midwayjs/core": "^4.0.0-beta.8",
33
33
  "@midwayjs/logger": "^3.0.0",
34
34
  "@types/amqplib": "0.10.6",
35
35
  "amqplib": "0.10.5",
@@ -50,5 +50,5 @@
50
50
  "type": "git",
51
51
  "url": "https://github.com/midwayjs/midway.git"
52
52
  },
53
- "gitHead": "6a221788112b4d998b3958e0a275579f42816c59"
53
+ "gitHead": "355e55949fdd132b0bdcb4830222a0a027e92ded"
54
54
  }