@sgedda/mockifyer-fetch 1.8.33 → 1.8.36
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/dist/clients/fetch-client.d.ts +2 -0
- package/dist/clients/fetch-client.js +4 -1
- package/dist/core-proxy.d.ts +7 -0
- package/dist/core-proxy.js +15 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +12 -6
- package/dist/metro-config.js +20 -0
- package/dist/utils/dashboard-redis-health.d.ts +1 -1
- package/dist/utils/dashboard-redis-health.js +3 -3
- package/package.json +2 -2
- package/src/clients/fetch-client.ts +5 -1
- package/src/core-proxy.ts +12 -0
- package/src/index.ts +18 -9
- package/src/metro-config.ts +24 -0
- package/src/utils/dashboard-redis-health.ts +1 -1
- package/tsconfig.json +5 -1
|
@@ -9,6 +9,7 @@ export declare class FetchHTTPClient extends BaseHTTPClient<any, HTTPResponse<an
|
|
|
9
9
|
private proxyRecordResponses;
|
|
10
10
|
private getClientId?;
|
|
11
11
|
private getStrictLaneScenario?;
|
|
12
|
+
private getUpstreamTlsInsecure?;
|
|
12
13
|
private getExplicitProxyScenarioContext?;
|
|
13
14
|
private clientIdSnapshot?;
|
|
14
15
|
private deviceId?;
|
|
@@ -26,6 +27,7 @@ export declare class FetchHTTPClient extends BaseHTTPClient<any, HTTPResponse<an
|
|
|
26
27
|
clientId?: string;
|
|
27
28
|
getClientId?: () => string | undefined;
|
|
28
29
|
getStrictLaneScenario?: () => boolean;
|
|
30
|
+
getUpstreamTlsInsecure?: () => boolean;
|
|
29
31
|
/** When false, skip `/api/proxy` and call the real URL (devtools-friendly passthrough). */
|
|
30
32
|
getExplicitProxyScenarioContext?: () => boolean;
|
|
31
33
|
deviceId?: string;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FetchHTTPClient = void 0;
|
|
4
4
|
const mockifyer_core_1 = require("@sgedda/mockifyer-core");
|
|
5
|
+
const core_proxy_1 = require("../core-proxy");
|
|
5
6
|
class FetchHTTPClient extends mockifyer_core_1.BaseHTTPClient {
|
|
6
7
|
constructor(config) {
|
|
7
8
|
super();
|
|
@@ -13,6 +14,7 @@ class FetchHTTPClient extends mockifyer_core_1.BaseHTTPClient {
|
|
|
13
14
|
this.proxyRecordResponses = config?.proxy?.recordResponses ?? false;
|
|
14
15
|
this.getClientId = config?.getClientId;
|
|
15
16
|
this.getStrictLaneScenario = config?.getStrictLaneScenario;
|
|
17
|
+
this.getUpstreamTlsInsecure = config?.getUpstreamTlsInsecure;
|
|
16
18
|
this.getExplicitProxyScenarioContext = config?.getExplicitProxyScenarioContext;
|
|
17
19
|
this.clientIdSnapshot = config?.clientId;
|
|
18
20
|
this.deviceId = config?.deviceId;
|
|
@@ -86,7 +88,7 @@ class FetchHTTPClient extends mockifyer_core_1.BaseHTTPClient {
|
|
|
86
88
|
headers.forEach((value, key) => {
|
|
87
89
|
headerRecord[key] = value;
|
|
88
90
|
});
|
|
89
|
-
return (0,
|
|
91
|
+
return (0, core_proxy_1.performDashboardProxyRequest)({
|
|
90
92
|
proxyBaseUrl: this.proxyBaseUrl,
|
|
91
93
|
url,
|
|
92
94
|
method: String(requestConfig.method || 'GET'),
|
|
@@ -100,6 +102,7 @@ class FetchHTTPClient extends mockifyer_core_1.BaseHTTPClient {
|
|
|
100
102
|
recordOnMiss: this.proxyRecordOnMiss,
|
|
101
103
|
recordResponses: this.proxyRecordResponses,
|
|
102
104
|
strictLaneScenario: this.getStrictLaneScenario?.() ?? true,
|
|
105
|
+
upstreamTlsInsecure: this.getUpstreamTlsInsecure?.() ?? false,
|
|
103
106
|
config,
|
|
104
107
|
fetchFn,
|
|
105
108
|
logTag: 'Mockifyer-Fetch',
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Proxy/dashboard helpers from core via subpath exports (RN-safe; avoids barrel resolution).
|
|
3
|
+
*/
|
|
4
|
+
export { applyProxyRecordOnMissEnv } from '@sgedda/mockifyer-core/utils/apply-proxy-record-on-miss-env';
|
|
5
|
+
export { mirrorProxyRecordingToClient } from '@sgedda/mockifyer-core/utils/mirror-proxy-recording-to-client';
|
|
6
|
+
export { initMockifyerForDashboardProxy, initMockifyerForLocalFilesystem, type InitMockifyerForDashboardProxyOptions, type InitMockifyerForLocalFilesystemOptions, } from '@sgedda/mockifyer-core/utils/init-mockifyer-presets';
|
|
7
|
+
export { performDashboardProxyRequest } from '@sgedda/mockifyer-core/utils/perform-dashboard-proxy-request';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.performDashboardProxyRequest = exports.initMockifyerForLocalFilesystem = exports.initMockifyerForDashboardProxy = exports.mirrorProxyRecordingToClient = exports.applyProxyRecordOnMissEnv = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Proxy/dashboard helpers from core via subpath exports (RN-safe; avoids barrel resolution).
|
|
6
|
+
*/
|
|
7
|
+
var apply_proxy_record_on_miss_env_1 = require("@sgedda/mockifyer-core/utils/apply-proxy-record-on-miss-env");
|
|
8
|
+
Object.defineProperty(exports, "applyProxyRecordOnMissEnv", { enumerable: true, get: function () { return apply_proxy_record_on_miss_env_1.applyProxyRecordOnMissEnv; } });
|
|
9
|
+
var mirror_proxy_recording_to_client_1 = require("@sgedda/mockifyer-core/utils/mirror-proxy-recording-to-client");
|
|
10
|
+
Object.defineProperty(exports, "mirrorProxyRecordingToClient", { enumerable: true, get: function () { return mirror_proxy_recording_to_client_1.mirrorProxyRecordingToClient; } });
|
|
11
|
+
var init_mockifyer_presets_1 = require("@sgedda/mockifyer-core/utils/init-mockifyer-presets");
|
|
12
|
+
Object.defineProperty(exports, "initMockifyerForDashboardProxy", { enumerable: true, get: function () { return init_mockifyer_presets_1.initMockifyerForDashboardProxy; } });
|
|
13
|
+
Object.defineProperty(exports, "initMockifyerForLocalFilesystem", { enumerable: true, get: function () { return init_mockifyer_presets_1.initMockifyerForLocalFilesystem; } });
|
|
14
|
+
var perform_dashboard_proxy_request_1 = require("@sgedda/mockifyer-core/utils/perform-dashboard-proxy-request");
|
|
15
|
+
Object.defineProperty(exports, "performDashboardProxyRequest", { enumerable: true, get: function () { return perform_dashboard_proxy_request_1.performDashboardProxyRequest; } });
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { MockifyerConfig, HTTPClient
|
|
1
|
+
import { MockifyerConfig, HTTPClient } from '@sgedda/mockifyer-core';
|
|
2
|
+
import { type InitMockifyerForDashboardProxyOptions, type InitMockifyerForLocalFilesystemOptions } from './core-proxy';
|
|
2
3
|
export interface MockifyerInstance extends HTTPClient {
|
|
3
4
|
reloadMockData: (syncFromProject?: boolean) => Promise<void>;
|
|
4
5
|
clearStaleCacheEntries: () => number;
|
package/dist/index.js
CHANGED
|
@@ -35,6 +35,7 @@ catch (e) {
|
|
|
35
35
|
// Import from core package
|
|
36
36
|
const mockifyer_core_1 = require("@sgedda/mockifyer-core");
|
|
37
37
|
const mockifyer_core_2 = require("@sgedda/mockifyer-core");
|
|
38
|
+
const core_proxy_1 = require("./core-proxy");
|
|
38
39
|
const fetch_client_1 = require("./clients/fetch-client");
|
|
39
40
|
class MockifyerClass {
|
|
40
41
|
/** Best-effort dashboard network log (skipped when traffic goes through `proxy.baseUrl`). */
|
|
@@ -181,6 +182,7 @@ class MockifyerClass {
|
|
|
181
182
|
clientId: this.config.clientId,
|
|
182
183
|
getClientId: () => this.config.clientId,
|
|
183
184
|
getStrictLaneScenario: () => (0, mockifyer_core_1.resolveProxyStrictLaneScenario)(this.config),
|
|
185
|
+
getUpstreamTlsInsecure: () => (0, mockifyer_core_1.resolveProxyUpstreamTlsInsecure)(this.config),
|
|
184
186
|
getExplicitProxyScenarioContext: () => (0, mockifyer_core_1.isExplicitProxyScenarioContext)(this.config),
|
|
185
187
|
deviceId: this.config.deviceId,
|
|
186
188
|
});
|
|
@@ -408,6 +410,10 @@ class MockifyerClass {
|
|
|
408
410
|
config.__mockifyer_bypass = true;
|
|
409
411
|
return config;
|
|
410
412
|
}
|
|
413
|
+
if ((0, mockifyer_core_1.shouldBypassMockifyerForUrl)(url, this.config.excludedUrls, this.config.baseUrl)) {
|
|
414
|
+
config.__mockifyer_bypass = true;
|
|
415
|
+
return config;
|
|
416
|
+
}
|
|
411
417
|
if (!(0, mockifyer_core_1.shouldApplyMockifyer)(this.activationMode, config.headers, {
|
|
412
418
|
useProxyLane: { proxyBaseUrl: this.config.proxy?.baseUrl, resolvedClientId: this.config.clientId },
|
|
413
419
|
})) {
|
|
@@ -671,7 +677,7 @@ class MockifyerClass {
|
|
|
671
677
|
const scenarioName = rec.scenarioName?.trim();
|
|
672
678
|
const mockData = rec.storedMock;
|
|
673
679
|
const providerType = this.config.databaseProvider?.type;
|
|
674
|
-
await (0,
|
|
680
|
+
await (0, core_proxy_1.mirrorProxyRecordingToClient)({
|
|
675
681
|
config: this.config,
|
|
676
682
|
mockDataPath: this.config.mockDataPath,
|
|
677
683
|
recording: rec,
|
|
@@ -741,10 +747,10 @@ class MockifyerClass {
|
|
|
741
747
|
return;
|
|
742
748
|
}
|
|
743
749
|
const url = response.config?.url || response.request?.responseURL || response.url || '';
|
|
744
|
-
|
|
745
|
-
if (url && (0, mockifyer_core_1.shouldExcludeUrl)(url, this.config.excludedUrls)) {
|
|
750
|
+
if (url && (0, mockifyer_core_1.shouldBypassMockifyerForUrl)(url, this.config.excludedUrls, this.config.baseUrl)) {
|
|
746
751
|
return;
|
|
747
752
|
}
|
|
753
|
+
const recordingExclusions = (0, mockifyer_core_1.resolveRecordingExclusions)(this.config);
|
|
748
754
|
if (url &&
|
|
749
755
|
(0, mockifyer_core_1.shouldExcludeRecording)(url, recordingExclusions, this.config.baseUrl)) {
|
|
750
756
|
return;
|
|
@@ -1114,7 +1120,7 @@ function setupMockifyer(config) {
|
|
|
1114
1120
|
if (typeof mockifyer_core_1.installNodeInboundRequestCorrelationCapture === 'function') {
|
|
1115
1121
|
(0, mockifyer_core_1.installNodeInboundRequestCorrelationCapture)();
|
|
1116
1122
|
}
|
|
1117
|
-
const resolvedConfig = (0,
|
|
1123
|
+
const resolvedConfig = (0, core_proxy_1.applyProxyRecordOnMissEnv)(config);
|
|
1118
1124
|
// Initialize logger with config level (default to 'info' if not specified)
|
|
1119
1125
|
(0, mockifyer_core_2.setLogLevel)(resolvedConfig.logging || 'info');
|
|
1120
1126
|
// Set environment variables for Metro middleware to read test generation config
|
|
@@ -1264,13 +1270,13 @@ function setupMockifyer(config) {
|
|
|
1264
1270
|
* For full control, use {@link setupMockifyer} directly.
|
|
1265
1271
|
*/
|
|
1266
1272
|
async function initMockifyerForDashboardProxy(options) {
|
|
1267
|
-
return (0,
|
|
1273
|
+
return (0, core_proxy_1.initMockifyerForDashboardProxy)({ ...options, useGlobalFetch: options.useGlobalFetch ?? options.config?.useGlobalFetch ?? true }, setupMockifyer);
|
|
1268
1274
|
}
|
|
1269
1275
|
/**
|
|
1270
1276
|
* Preset: local filesystem mocks. No dashboard proxy.
|
|
1271
1277
|
*/
|
|
1272
1278
|
function initMockifyerForLocalFilesystem(options = {}) {
|
|
1273
|
-
return (0,
|
|
1279
|
+
return (0, core_proxy_1.initMockifyerForLocalFilesystem)({ ...options, useGlobalFetch: options.useGlobalFetch ?? options.config?.useGlobalFetch ?? true }, setupMockifyer);
|
|
1274
1280
|
}
|
|
1275
1281
|
/** Shared with {@link setupMockifyerForReactNative} strict-proxy branching. */
|
|
1276
1282
|
var dashboard_redis_health_1 = require("./utils/dashboard-redis-health");
|
package/dist/metro-config.js
CHANGED
|
@@ -75,6 +75,22 @@ function isMockifyerStubbedModule(moduleName) {
|
|
|
75
75
|
return (NODE_BUILTINS.includes(moduleName) ||
|
|
76
76
|
OPTIONAL_RN_PEER_MODULES.includes(moduleName));
|
|
77
77
|
}
|
|
78
|
+
/** Metro often resolves `@sgedda/mockifyer-core` to `main` instead of the RN entry. */
|
|
79
|
+
function resolveMockifyerCoreReactNativeEntry(moduleName, platform) {
|
|
80
|
+
if (moduleName !== '@sgedda/mockifyer-core') {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
if (platform === 'web') {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
try {
|
|
87
|
+
const filePath = require.resolve('@sgedda/mockifyer-core/dist/index.react-native.js');
|
|
88
|
+
return { filePath, type: 'sourceFile' };
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
78
94
|
/**
|
|
79
95
|
* Configure Metro bundler for Mockifyer
|
|
80
96
|
*
|
|
@@ -151,6 +167,10 @@ function configureMetroForMockifyer(config, options) {
|
|
|
151
167
|
type: 'sourceFile',
|
|
152
168
|
};
|
|
153
169
|
}
|
|
170
|
+
const mockifyerCoreRn = resolveMockifyerCoreReactNativeEntry(moduleName, platform);
|
|
171
|
+
if (mockifyerCoreRn) {
|
|
172
|
+
return mockifyerCoreRn;
|
|
173
|
+
}
|
|
154
174
|
// Call existing resolver if present
|
|
155
175
|
if (existingResolveRequest) {
|
|
156
176
|
const result = existingResolveRequest(context, moduleName, platform);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { canUseDashboardCentralProxy, canUseDashboardRedisProxy, type DashboardHealthPayload, } from '@sgedda/mockifyer-core';
|
|
1
|
+
export { canUseDashboardCentralProxy, canUseDashboardRedisProxy, type DashboardHealthPayload, } from '@sgedda/mockifyer-core/utils/dashboard-central-proxy-health';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.canUseDashboardRedisProxy = exports.canUseDashboardCentralProxy = void 0;
|
|
4
|
-
var
|
|
5
|
-
Object.defineProperty(exports, "canUseDashboardCentralProxy", { enumerable: true, get: function () { return
|
|
6
|
-
Object.defineProperty(exports, "canUseDashboardRedisProxy", { enumerable: true, get: function () { return
|
|
4
|
+
var dashboard_central_proxy_health_1 = require("@sgedda/mockifyer-core/utils/dashboard-central-proxy-health");
|
|
5
|
+
Object.defineProperty(exports, "canUseDashboardCentralProxy", { enumerable: true, get: function () { return dashboard_central_proxy_health_1.canUseDashboardCentralProxy; } });
|
|
6
|
+
Object.defineProperty(exports, "canUseDashboardRedisProxy", { enumerable: true, get: function () { return dashboard_central_proxy_health_1.canUseDashboardRedisProxy; } });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sgedda/mockifyer-fetch",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.36",
|
|
4
4
|
"description": "Mockifyer for Fetch - API mocking and logging utility for storing and replaying API responses",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
},
|
|
50
50
|
"license": "MIT",
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@sgedda/mockifyer-core": "^1.10.
|
|
52
|
+
"@sgedda/mockifyer-core": "^1.10.10"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@types/node": "^20.11.24",
|
|
@@ -8,8 +8,8 @@ import {
|
|
|
8
8
|
getOutboundMockifyerDeviceIdHeader,
|
|
9
9
|
MOCKIFYER_CLIENT_ID_HEADER,
|
|
10
10
|
MOCKIFYER_DEVICE_ID_HEADER,
|
|
11
|
-
performDashboardProxyRequest,
|
|
12
11
|
} from '@sgedda/mockifyer-core';
|
|
12
|
+
import { performDashboardProxyRequest } from '../core-proxy';
|
|
13
13
|
|
|
14
14
|
export class FetchHTTPClient extends BaseHTTPClient<any, HTTPResponse<any>> {
|
|
15
15
|
private baseUrl?: string;
|
|
@@ -21,6 +21,7 @@ export class FetchHTTPClient extends BaseHTTPClient<any, HTTPResponse<any>> {
|
|
|
21
21
|
private proxyRecordResponses: boolean;
|
|
22
22
|
private getClientId?: () => string | undefined;
|
|
23
23
|
private getStrictLaneScenario?: () => boolean;
|
|
24
|
+
private getUpstreamTlsInsecure?: () => boolean;
|
|
24
25
|
private getExplicitProxyScenarioContext?: () => boolean;
|
|
25
26
|
private clientIdSnapshot?: string;
|
|
26
27
|
private deviceId?: string;
|
|
@@ -39,6 +40,7 @@ export class FetchHTTPClient extends BaseHTTPClient<any, HTTPResponse<any>> {
|
|
|
39
40
|
clientId?: string;
|
|
40
41
|
getClientId?: () => string | undefined;
|
|
41
42
|
getStrictLaneScenario?: () => boolean;
|
|
43
|
+
getUpstreamTlsInsecure?: () => boolean;
|
|
42
44
|
/** When false, skip `/api/proxy` and call the real URL (devtools-friendly passthrough). */
|
|
43
45
|
getExplicitProxyScenarioContext?: () => boolean;
|
|
44
46
|
deviceId?: string;
|
|
@@ -52,6 +54,7 @@ export class FetchHTTPClient extends BaseHTTPClient<any, HTTPResponse<any>> {
|
|
|
52
54
|
this.proxyRecordResponses = config?.proxy?.recordResponses ?? false;
|
|
53
55
|
this.getClientId = config?.getClientId;
|
|
54
56
|
this.getStrictLaneScenario = config?.getStrictLaneScenario;
|
|
57
|
+
this.getUpstreamTlsInsecure = config?.getUpstreamTlsInsecure;
|
|
55
58
|
this.getExplicitProxyScenarioContext = config?.getExplicitProxyScenarioContext;
|
|
56
59
|
this.clientIdSnapshot = config?.clientId;
|
|
57
60
|
this.deviceId = config?.deviceId;
|
|
@@ -149,6 +152,7 @@ export class FetchHTTPClient extends BaseHTTPClient<any, HTTPResponse<any>> {
|
|
|
149
152
|
recordOnMiss: this.proxyRecordOnMiss,
|
|
150
153
|
recordResponses: this.proxyRecordResponses,
|
|
151
154
|
strictLaneScenario: this.getStrictLaneScenario?.() ?? true,
|
|
155
|
+
upstreamTlsInsecure: this.getUpstreamTlsInsecure?.() ?? false,
|
|
152
156
|
config,
|
|
153
157
|
fetchFn,
|
|
154
158
|
logTag: 'Mockifyer-Fetch',
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Proxy/dashboard helpers from core via subpath exports (RN-safe; avoids barrel resolution).
|
|
3
|
+
*/
|
|
4
|
+
export { applyProxyRecordOnMissEnv } from '@sgedda/mockifyer-core/utils/apply-proxy-record-on-miss-env';
|
|
5
|
+
export { mirrorProxyRecordingToClient } from '@sgedda/mockifyer-core/utils/mirror-proxy-recording-to-client';
|
|
6
|
+
export {
|
|
7
|
+
initMockifyerForDashboardProxy,
|
|
8
|
+
initMockifyerForLocalFilesystem,
|
|
9
|
+
type InitMockifyerForDashboardProxyOptions,
|
|
10
|
+
type InitMockifyerForLocalFilesystemOptions,
|
|
11
|
+
} from '@sgedda/mockifyer-core/utils/init-mockifyer-presets';
|
|
12
|
+
export { performDashboardProxyRequest } from '@sgedda/mockifyer-core/utils/perform-dashboard-proxy-request';
|
package/src/index.ts
CHANGED
|
@@ -35,7 +35,7 @@ import {
|
|
|
35
35
|
checkRequestLimit,
|
|
36
36
|
prepareMockResponseBody,
|
|
37
37
|
getCurrentDate,
|
|
38
|
-
|
|
38
|
+
shouldBypassMockifyerForUrl,
|
|
39
39
|
resolveRecordingExclusions,
|
|
40
40
|
shouldExcludeRecording,
|
|
41
41
|
mockPassesThroughToRealApi,
|
|
@@ -49,6 +49,7 @@ import {
|
|
|
49
49
|
resolveClientId,
|
|
50
50
|
resolveExplicitClientIdOnly,
|
|
51
51
|
resolveProxyStrictLaneScenario,
|
|
52
|
+
resolveProxyUpstreamTlsInsecure,
|
|
52
53
|
registerMockifyerInstance,
|
|
53
54
|
logMockifyerInitSummary,
|
|
54
55
|
tryGetClientIdFromLaunchArguments,
|
|
@@ -56,12 +57,6 @@ import {
|
|
|
56
57
|
resolveActivationMode,
|
|
57
58
|
shouldApplyMockifyer,
|
|
58
59
|
isExplicitProxyScenarioContext,
|
|
59
|
-
applyProxyRecordOnMissEnv,
|
|
60
|
-
mirrorProxyRecordingToClient,
|
|
61
|
-
initMockifyerForDashboardProxy as coreInitMockifyerForDashboardProxy,
|
|
62
|
-
initMockifyerForLocalFilesystem as coreInitMockifyerForLocalFilesystem,
|
|
63
|
-
type InitMockifyerForDashboardProxyOptions,
|
|
64
|
-
type InitMockifyerForLocalFilesystemOptions,
|
|
65
60
|
newRecordingUsesAlwaysUseRealApi,
|
|
66
61
|
shouldBlockLocalMockRecording,
|
|
67
62
|
resolveStrictScenarioResolution,
|
|
@@ -74,6 +69,14 @@ import {
|
|
|
74
69
|
installNodeInboundRequestCorrelationCapture,
|
|
75
70
|
} from '@sgedda/mockifyer-core';
|
|
76
71
|
import { logger, setLogLevel } from '@sgedda/mockifyer-core';
|
|
72
|
+
import {
|
|
73
|
+
applyProxyRecordOnMissEnv,
|
|
74
|
+
mirrorProxyRecordingToClient,
|
|
75
|
+
initMockifyerForDashboardProxy as coreInitMockifyerForDashboardProxy,
|
|
76
|
+
initMockifyerForLocalFilesystem as coreInitMockifyerForLocalFilesystem,
|
|
77
|
+
type InitMockifyerForDashboardProxyOptions,
|
|
78
|
+
type InitMockifyerForLocalFilesystemOptions,
|
|
79
|
+
} from './core-proxy';
|
|
77
80
|
|
|
78
81
|
import { FetchHTTPClient } from './clients/fetch-client';
|
|
79
82
|
|
|
@@ -251,6 +254,7 @@ class MockifyerClass {
|
|
|
251
254
|
clientId: this.config.clientId,
|
|
252
255
|
getClientId: () => this.config.clientId,
|
|
253
256
|
getStrictLaneScenario: () => resolveProxyStrictLaneScenario(this.config),
|
|
257
|
+
getUpstreamTlsInsecure: () => resolveProxyUpstreamTlsInsecure(this.config),
|
|
254
258
|
getExplicitProxyScenarioContext: () => isExplicitProxyScenarioContext(this.config),
|
|
255
259
|
deviceId: (this.config as any).deviceId,
|
|
256
260
|
});
|
|
@@ -527,6 +531,11 @@ class MockifyerClass {
|
|
|
527
531
|
return config;
|
|
528
532
|
}
|
|
529
533
|
|
|
534
|
+
if (shouldBypassMockifyerForUrl(url, this.config.excludedUrls, this.config.baseUrl)) {
|
|
535
|
+
(config as any).__mockifyer_bypass = true;
|
|
536
|
+
return config;
|
|
537
|
+
}
|
|
538
|
+
|
|
530
539
|
if (
|
|
531
540
|
!shouldApplyMockifyer(this.activationMode, config.headers, {
|
|
532
541
|
useProxyLane: { proxyBaseUrl: this.config.proxy?.baseUrl, resolvedClientId: this.config.clientId },
|
|
@@ -938,10 +947,10 @@ class MockifyerClass {
|
|
|
938
947
|
}
|
|
939
948
|
|
|
940
949
|
const url = response.config?.url || (response as any).request?.responseURL || (response as any).url || '';
|
|
941
|
-
|
|
942
|
-
if (url && shouldExcludeUrl(url, this.config.excludedUrls)) {
|
|
950
|
+
if (url && shouldBypassMockifyerForUrl(url, this.config.excludedUrls, this.config.baseUrl)) {
|
|
943
951
|
return;
|
|
944
952
|
}
|
|
953
|
+
const recordingExclusions = resolveRecordingExclusions(this.config);
|
|
945
954
|
if (
|
|
946
955
|
url &&
|
|
947
956
|
shouldExcludeRecording(url, recordingExclusions, this.config.baseUrl)
|
package/src/metro-config.ts
CHANGED
|
@@ -97,6 +97,25 @@ function isMockifyerStubbedModule(moduleName: string): boolean {
|
|
|
97
97
|
);
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
+
/** Metro often resolves `@sgedda/mockifyer-core` to `main` instead of the RN entry. */
|
|
101
|
+
function resolveMockifyerCoreReactNativeEntry(
|
|
102
|
+
moduleName: string,
|
|
103
|
+
platform: string | null
|
|
104
|
+
): { filePath: string; type: 'sourceFile' } | null {
|
|
105
|
+
if (moduleName !== '@sgedda/mockifyer-core') {
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
if (platform === 'web') {
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
try {
|
|
112
|
+
const filePath = require.resolve('@sgedda/mockifyer-core/dist/index.react-native.js');
|
|
113
|
+
return { filePath, type: 'sourceFile' };
|
|
114
|
+
} catch {
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
100
119
|
/**
|
|
101
120
|
* Options for configuring Metro for Mockifyer
|
|
102
121
|
*/
|
|
@@ -201,6 +220,11 @@ export function configureMetroForMockifyer(
|
|
|
201
220
|
};
|
|
202
221
|
}
|
|
203
222
|
|
|
223
|
+
const mockifyerCoreRn = resolveMockifyerCoreReactNativeEntry(moduleName, platform);
|
|
224
|
+
if (mockifyerCoreRn) {
|
|
225
|
+
return mockifyerCoreRn;
|
|
226
|
+
}
|
|
227
|
+
|
|
204
228
|
// Call existing resolver if present
|
|
205
229
|
if (existingResolveRequest) {
|
|
206
230
|
const result = existingResolveRequest(context, moduleName, platform);
|
package/tsconfig.json
CHANGED
|
@@ -11,7 +11,11 @@
|
|
|
11
11
|
"skipLibCheck": true,
|
|
12
12
|
"forceConsistentCasingInFileNames": true,
|
|
13
13
|
"resolveJsonModule": true,
|
|
14
|
-
"moduleResolution": "node"
|
|
14
|
+
"moduleResolution": "node",
|
|
15
|
+
"baseUrl": ".",
|
|
16
|
+
"paths": {
|
|
17
|
+
"@sgedda/mockifyer-core/utils/*": ["../mockifyer-core/dist/utils/*"]
|
|
18
|
+
}
|
|
15
19
|
},
|
|
16
20
|
"include": ["src/**/*"],
|
|
17
21
|
"exclude": ["node_modules", "dist"]
|