@sgedda/mockifyer-fetch 1.8.25 → 1.8.26

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.
@@ -7,6 +7,7 @@ export declare class FetchHTTPClient extends BaseHTTPClient<any, HTTPResponse<an
7
7
  private proxyScenario?;
8
8
  private proxyRecordOnMiss;
9
9
  private getClientId?;
10
+ private getStrictLaneScenario?;
10
11
  private clientIdSnapshot?;
11
12
  private deviceId?;
12
13
  constructor(config?: {
@@ -16,9 +17,11 @@ export declare class FetchHTTPClient extends BaseHTTPClient<any, HTTPResponse<an
16
17
  baseUrl: string;
17
18
  scenario?: string;
18
19
  recordOnMiss?: boolean;
20
+ strictLaneScenario?: boolean;
19
21
  };
20
22
  clientId?: string;
21
23
  getClientId?: () => string | undefined;
24
+ getStrictLaneScenario?: () => boolean;
22
25
  deviceId?: string;
23
26
  });
24
27
  private resolvedClientLane;
@@ -13,6 +13,7 @@ class FetchHTTPClient extends mockifyer_core_1.BaseHTTPClient {
13
13
  this.proxyScenario = config?.proxy?.scenario;
14
14
  this.proxyRecordOnMiss = config?.proxy?.recordOnMiss ?? false;
15
15
  this.getClientId = config?.getClientId;
16
+ this.getStrictLaneScenario = config?.getStrictLaneScenario;
16
17
  this.clientIdSnapshot = config?.clientId;
17
18
  this.deviceId = config?.deviceId;
18
19
  }
@@ -94,6 +95,7 @@ class FetchHTTPClient extends mockifyer_core_1.BaseHTTPClient {
94
95
  body: config.data ?? null,
95
96
  scenario: this.proxyScenario,
96
97
  record: this.proxyRecordOnMiss,
98
+ strictLaneScenario: this.getStrictLaneScenario?.() ?? true,
97
99
  }),
98
100
  });
99
101
  if (!proxyResponse.ok) {
package/dist/index.js CHANGED
@@ -97,11 +97,7 @@ class MockifyerClass {
97
97
  else {
98
98
  this.config.clientId = (0, mockifyer_core_1.resolveClientId)(this.config);
99
99
  }
100
- mockifyer_core_2.logger.info(`[Mockifyer-Fetch] clientId: ${this.config.clientId}`);
101
100
  this.activationMode = (0, mockifyer_core_1.resolveActivationMode)(this.config);
102
- if (this.activationMode !== 'always') {
103
- mockifyer_core_2.logger.info(`[Mockifyer-Fetch] activationMode: ${this.activationMode}`);
104
- }
105
101
  // Initialize test generator if test generation is enabled
106
102
  if (config.generateTests?.enabled) {
107
103
  this.testGenerator = new mockifyer_core_1.TestGenerator();
@@ -137,6 +133,7 @@ class MockifyerClass {
137
133
  proxy: config.proxy,
138
134
  clientId: this.config.clientId,
139
135
  getClientId: () => this.config.clientId,
136
+ getStrictLaneScenario: () => (0, mockifyer_core_1.resolveProxyStrictLaneScenario)(this.config),
140
137
  deviceId: this.config.deviceId,
141
138
  });
142
139
  if (!config.recordSameEndpoints) {
@@ -146,6 +143,10 @@ class MockifyerClass {
146
143
  this.setupMockResponses();
147
144
  // Set up response interceptor to save responses when recordMode is enabled
148
145
  this.setupResponseInterceptor();
146
+ (0, mockifyer_core_1.logMockifyerInitSummary)(this.config, {
147
+ runtimeMode: this.config.runtimeMode,
148
+ headline: this.config.initLog?.headline,
149
+ });
149
150
  }
150
151
  ensureMockDataDirectory() {
151
152
  // Only use fs if available (Node.js environment) and no database provider is set
@@ -111,20 +111,18 @@ async function setupMockifyerForReactNative(options) {
111
111
  }
112
112
  : {}),
113
113
  };
114
+ const devInitHeadline = (strictProxy) => strictProxy
115
+ ? 'React Native dev · dashboard Redis proxy'
116
+ : 'React Native dev · hybrid (device + Metro)';
114
117
  const isEnabled = resolvedRuntimeMode === 'on' ||
115
118
  (resolvedRuntimeMode === 'launch_client' && Boolean(clientIdFromLaunchArgs));
116
119
  if (!isEnabled) {
117
- const hint = resolvedRuntimeMode === 'off'
118
- ? 'MOCKIFYER_MODE=off (or runtimeMode off) — launch args are ignored.'
119
- : resolvedRuntimeMode === 'launch_client'
120
- ? 'MOCKIFYER_MODE=launch_client — pass mockifyerClientId via launch args, or set MOCKIFYER_MODE=on for always-on dev.'
121
- : 'Adjust MOCKIFYER_MODE / runtimeMode.';
122
- mockifyer_core_2.logger.info(`[Mockifyer] Not activated (${hint})`);
120
+ (0, mockifyer_core_2.logMockifyerNotActivated)(resolvedRuntimeMode, {
121
+ launchClientIdKey,
122
+ hadLaunchClientId: Boolean(clientIdFromLaunchArgs),
123
+ });
123
124
  return { status: 'not_activated', instance: null };
124
125
  }
125
- if (clientIdFromLaunchArgs && !useLaunchArgumentsClientId) {
126
- mockifyer_core_2.logger.info(`[Mockifyer] Enabled via launch argument "${launchClientIdKey}" (E2E lane "${clientIdFromLaunchArgs}")`);
127
- }
128
126
  if (isDev === true) {
129
127
  const strictProxyEnabled = await canUseStrictRedisProxy(proxyBaseUrl);
130
128
  // DEVELOPMENT MODE (React Native app running in dev)
@@ -166,17 +164,10 @@ async function setupMockifyerForReactNative(options) {
166
164
  ? { baseUrl: proxyBaseUrl, scenario: proxyScenario, recordOnMiss: proxyShouldRecordOnMiss }
167
165
  : undefined,
168
166
  ...mergedConfig,
167
+ initLog: { headline: mergedConfig.initLog?.headline ?? devInitHeadline(strictProxyEnabled) },
169
168
  });
170
- if (strictProxyEnabled) {
171
- mockifyer_core_2.logger.info('[Mockifyer] Development mode: Strict proxy enabled (dashboard Redis is healthy) — local mocks disabled');
172
- }
173
- else {
174
- mockifyer_core_2.logger.info('[Mockifyer] Development mode: Using Hybrid provider (device + project folder)');
175
- mockifyer_core_2.logger.info(`[Mockifyer] Metro endpoint: http://localhost:${metroPort}/mockifyer-save`);
176
- mockifyer_core_2.logger.info(`[Mockifyer] Project→device sync: /mockifyer-sync-to-device-manifest + per-file fetch (on reloadMockData); Metro port ${metroPort}`);
177
- }
178
- if (recordMode) {
179
- mockifyer_core_2.logger.info('[Mockifyer] Recording mode enabled - new API responses will be saved');
169
+ if (!strictProxyEnabled) {
170
+ mockifyer_core_2.logger.info(`[Mockifyer] Metro: http://localhost:${metroPort}/mockifyer-save · scenario: /mockifyer-scenario-config`);
180
171
  }
181
172
  if (!strictProxyEnabled) {
182
173
  // Pull repo mock-data onto device once Metro + provider are ready (HybridProvider.reload)
@@ -215,8 +206,11 @@ async function setupMockifyerForReactNative(options) {
215
206
  ? { baseUrl: proxyBaseUrl, scenario: proxyScenario, recordOnMiss: proxyShouldRecordOnMiss }
216
207
  : undefined,
217
208
  ...mergedConfig,
209
+ initLog: {
210
+ headline: mergedConfig.initLog?.headline ??
211
+ `React Native production · ${mockDataArray.length} bundled mock(s)`,
212
+ },
218
213
  });
219
- mockifyer_core_2.logger.info(`[Mockifyer] Production mode: Loaded ${mockDataArray.length} mocks from bundle`);
220
214
  return { status: 'active', instance };
221
215
  }
222
216
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sgedda/mockifyer-fetch",
3
- "version": "1.8.25",
3
+ "version": "1.8.26",
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.8.30"
52
+ "@sgedda/mockifyer-core": "^1.8.31"
53
53
  },
54
54
  "devDependencies": {
55
55
  "@types/node": "^20.11.24",
@@ -15,15 +15,17 @@ export class FetchHTTPClient extends BaseHTTPClient<any, HTTPResponse<any>> {
15
15
  private proxyScenario?: string;
16
16
  private proxyRecordOnMiss: boolean;
17
17
  private getClientId?: () => string | undefined;
18
+ private getStrictLaneScenario?: () => boolean;
18
19
  private clientIdSnapshot?: string;
19
20
  private deviceId?: string;
20
21
 
21
22
  constructor(config?: {
22
23
  baseUrl?: string;
23
24
  defaultHeaders?: Record<string, string>;
24
- proxy?: { baseUrl: string; scenario?: string; recordOnMiss?: boolean };
25
+ proxy?: { baseUrl: string; scenario?: string; recordOnMiss?: boolean; strictLaneScenario?: boolean };
25
26
  clientId?: string;
26
27
  getClientId?: () => string | undefined;
28
+ getStrictLaneScenario?: () => boolean;
27
29
  deviceId?: string;
28
30
  }) {
29
31
  super();
@@ -33,6 +35,7 @@ export class FetchHTTPClient extends BaseHTTPClient<any, HTTPResponse<any>> {
33
35
  this.proxyScenario = config?.proxy?.scenario;
34
36
  this.proxyRecordOnMiss = config?.proxy?.recordOnMiss ?? false;
35
37
  this.getClientId = config?.getClientId;
38
+ this.getStrictLaneScenario = config?.getStrictLaneScenario;
36
39
  this.clientIdSnapshot = config?.clientId;
37
40
  this.deviceId = config?.deviceId;
38
41
  }
@@ -122,6 +125,7 @@ export class FetchHTTPClient extends BaseHTTPClient<any, HTTPResponse<any>> {
122
125
  body: config.data ?? null,
123
126
  scenario: this.proxyScenario,
124
127
  record: this.proxyRecordOnMiss,
128
+ strictLaneScenario: this.getStrictLaneScenario?.() ?? true,
125
129
  }),
126
130
  });
127
131
  if (!proxyResponse.ok) {
package/src/index.ts CHANGED
@@ -38,7 +38,9 @@ import {
38
38
  shouldExcludeUrl,
39
39
  mockPassesThroughToRealApi,
40
40
  resolveClientId,
41
+ resolveProxyStrictLaneScenario,
41
42
  registerMockifyerInstance,
43
+ logMockifyerInitSummary,
42
44
  tryGetClientIdFromLaunchArguments,
43
45
  MOCKIFYER_LAUNCH_ARGUMENT_CLIENT_ID_KEY,
44
46
  resolveActivationMode,
@@ -132,12 +134,7 @@ class MockifyerClass {
132
134
  } else {
133
135
  this.config.clientId = resolveClientId(this.config);
134
136
  }
135
- logger.info(`[Mockifyer-Fetch] clientId: ${this.config.clientId}`);
136
-
137
137
  this.activationMode = resolveActivationMode(this.config);
138
- if (this.activationMode !== 'always') {
139
- logger.info(`[Mockifyer-Fetch] activationMode: ${this.activationMode}`);
140
- }
141
138
 
142
139
  // Initialize test generator if test generation is enabled
143
140
  if (config.generateTests?.enabled) {
@@ -170,12 +167,13 @@ class MockifyerClass {
170
167
  }
171
168
 
172
169
  // Create fetch HTTP client
173
- this.httpClient = new FetchHTTPClient({
174
- baseUrl: config.baseUrl,
170
+ this.httpClient = new FetchHTTPClient({
171
+ baseUrl: config.baseUrl,
175
172
  defaultHeaders: config.defaultHeaders,
176
173
  proxy: config.proxy,
177
174
  clientId: this.config.clientId,
178
175
  getClientId: () => this.config.clientId,
176
+ getStrictLaneScenario: () => resolveProxyStrictLaneScenario(this.config),
179
177
  deviceId: (this.config as any).deviceId,
180
178
  });
181
179
 
@@ -187,6 +185,11 @@ class MockifyerClass {
187
185
 
188
186
  // Set up response interceptor to save responses when recordMode is enabled
189
187
  this.setupResponseInterceptor();
188
+
189
+ logMockifyerInitSummary(this.config, {
190
+ runtimeMode: this.config.runtimeMode,
191
+ headline: this.config.initLog?.headline,
192
+ });
190
193
  }
191
194
 
192
195
  private ensureMockDataDirectory(): void {
@@ -13,6 +13,7 @@ import {
13
13
  MOCKIFYER_LAUNCH_ARGUMENT_CLIENT_ID_KEY,
14
14
  tryGetClientIdFromLaunchArguments,
15
15
  resolveMockifyerRuntimeMode,
16
+ logMockifyerNotActivated,
16
17
  type MockifyerRuntimeMode,
17
18
  } from '@sgedda/mockifyer-core';
18
19
 
@@ -210,26 +211,22 @@ export async function setupMockifyerForReactNative(
210
211
  : {}),
211
212
  };
212
213
 
214
+ const devInitHeadline = (strictProxy: boolean) =>
215
+ strictProxy
216
+ ? 'React Native dev · dashboard Redis proxy'
217
+ : 'React Native dev · hybrid (device + Metro)';
218
+
213
219
  const isEnabled =
214
220
  resolvedRuntimeMode === 'on' ||
215
221
  (resolvedRuntimeMode === 'launch_client' && Boolean(clientIdFromLaunchArgs));
216
222
  if (!isEnabled) {
217
- const hint =
218
- resolvedRuntimeMode === 'off'
219
- ? 'MOCKIFYER_MODE=off (or runtimeMode off) — launch args are ignored.'
220
- : resolvedRuntimeMode === 'launch_client'
221
- ? 'MOCKIFYER_MODE=launch_client — pass mockifyerClientId via launch args, or set MOCKIFYER_MODE=on for always-on dev.'
222
- : 'Adjust MOCKIFYER_MODE / runtimeMode.';
223
- logger.info(`[Mockifyer] Not activated (${hint})`);
223
+ logMockifyerNotActivated(resolvedRuntimeMode, {
224
+ launchClientIdKey,
225
+ hadLaunchClientId: Boolean(clientIdFromLaunchArgs),
226
+ });
224
227
  return { status: 'not_activated', instance: null } as const;
225
228
  }
226
229
 
227
- if (clientIdFromLaunchArgs && !useLaunchArgumentsClientId) {
228
- logger.info(
229
- `[Mockifyer] Enabled via launch argument "${launchClientIdKey}" (E2E lane "${clientIdFromLaunchArgs}")`
230
- );
231
- }
232
-
233
230
  if (isDev === true) {
234
231
  const strictProxyEnabled = await canUseStrictRedisProxy(proxyBaseUrl);
235
232
 
@@ -275,19 +272,11 @@ export async function setupMockifyerForReactNative(
275
272
  ? { baseUrl: proxyBaseUrl, scenario: proxyScenario, recordOnMiss: proxyShouldRecordOnMiss }
276
273
  : undefined,
277
274
  ...mergedConfig,
275
+ initLog: { headline: mergedConfig.initLog?.headline ?? devInitHeadline(strictProxyEnabled) },
278
276
  });
279
277
 
280
- if (strictProxyEnabled) {
281
- logger.info('[Mockifyer] Development mode: Strict proxy enabled (dashboard Redis is healthy) — local mocks disabled');
282
- } else {
283
- logger.info('[Mockifyer] Development mode: Using Hybrid provider (device + project folder)');
284
- logger.info(`[Mockifyer] Metro endpoint: http://localhost:${metroPort}/mockifyer-save`);
285
- logger.info(
286
- `[Mockifyer] Project→device sync: /mockifyer-sync-to-device-manifest + per-file fetch (on reloadMockData); Metro port ${metroPort}`
287
- );
288
- }
289
- if (recordMode) {
290
- logger.info('[Mockifyer] Recording mode enabled - new API responses will be saved');
278
+ if (!strictProxyEnabled) {
279
+ logger.info(`[Mockifyer] Metro: http://localhost:${metroPort}/mockifyer-save · scenario: /mockifyer-scenario-config`);
291
280
  }
292
281
 
293
282
  if (!strictProxyEnabled) {
@@ -332,9 +321,13 @@ export async function setupMockifyerForReactNative(
332
321
  ? { baseUrl: proxyBaseUrl, scenario: proxyScenario, recordOnMiss: proxyShouldRecordOnMiss }
333
322
  : undefined,
334
323
  ...mergedConfig,
324
+ initLog: {
325
+ headline:
326
+ mergedConfig.initLog?.headline ??
327
+ `React Native production · ${mockDataArray.length} bundled mock(s)`,
328
+ },
335
329
  });
336
330
 
337
- logger.info(`[Mockifyer] Production mode: Loaded ${mockDataArray.length} mocks from bundle`);
338
331
  return { status: 'active', instance } as const;
339
332
  }
340
333
  }