@sgedda/mockifyer-fetch 1.8.14 → 1.8.17

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 clientId?;
10
+ private deviceId?;
10
11
  constructor(config?: {
11
12
  baseUrl?: string;
12
13
  defaultHeaders?: Record<string, string>;
@@ -16,6 +17,7 @@ export declare class FetchHTTPClient extends BaseHTTPClient<any, HTTPResponse<an
16
17
  recordOnMiss?: boolean;
17
18
  };
18
19
  clientId?: string;
20
+ deviceId?: string;
19
21
  });
20
22
  protected performRequest<D = any>(config: HTTPRequestConfig<D>): Promise<HTTPResponse<any>>;
21
23
  protected getDefaultHeaders(): Record<string, string>;
@@ -11,6 +11,7 @@ class FetchHTTPClient extends mockifyer_core_1.BaseHTTPClient {
11
11
  this.proxyScenario = config?.proxy?.scenario;
12
12
  this.proxyRecordOnMiss = config?.proxy?.recordOnMiss ?? false;
13
13
  this.clientId = config?.clientId;
14
+ this.deviceId = config?.deviceId;
14
15
  }
15
16
  async performRequest(config) {
16
17
  // Check if this is a mock response (set by Mockifyer interceptor)
@@ -60,11 +61,13 @@ class FetchHTTPClient extends mockifyer_core_1.BaseHTTPClient {
60
61
  headers: {
61
62
  'content-type': 'application/json',
62
63
  ...(this.clientId ? { 'x-mockifyer-client-id': this.clientId } : {}),
64
+ ...(this.deviceId ? { 'x-mockifyer-device-id': this.deviceId } : {}),
63
65
  },
64
66
  body: JSON.stringify({
65
67
  url,
66
68
  method: requestConfig.method,
67
69
  clientId: this.clientId,
70
+ deviceId: this.deviceId,
68
71
  headers: (() => {
69
72
  const out = {};
70
73
  headers.forEach((value, key) => {
package/dist/index.js CHANGED
@@ -118,6 +118,7 @@ class MockifyerClass {
118
118
  defaultHeaders: config.defaultHeaders,
119
119
  proxy: config.proxy,
120
120
  clientId: this.config.clientId,
121
+ deviceId: this.config.deviceId,
121
122
  });
122
123
  if (!config.recordSameEndpoints) {
123
124
  this.loadMockData();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sgedda/mockifyer-fetch",
3
- "version": "1.8.14",
3
+ "version": "1.8.17",
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",
@@ -46,7 +46,7 @@
46
46
  "author": "sgedda",
47
47
  "license": "MIT",
48
48
  "dependencies": {
49
- "@sgedda/mockifyer-core": "^1.8.12"
49
+ "@sgedda/mockifyer-core": "^1.8.22"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@types/node": "^20.11.24",
@@ -8,12 +8,14 @@ export class FetchHTTPClient extends BaseHTTPClient<any, HTTPResponse<any>> {
8
8
  private proxyScenario?: string;
9
9
  private proxyRecordOnMiss: boolean;
10
10
  private clientId?: string;
11
+ private deviceId?: string;
11
12
 
12
13
  constructor(config?: {
13
14
  baseUrl?: string;
14
15
  defaultHeaders?: Record<string, string>;
15
16
  proxy?: { baseUrl: string; scenario?: string; recordOnMiss?: boolean };
16
17
  clientId?: string;
18
+ deviceId?: string;
17
19
  }) {
18
20
  super();
19
21
  this.baseUrl = config?.baseUrl;
@@ -22,6 +24,7 @@ export class FetchHTTPClient extends BaseHTTPClient<any, HTTPResponse<any>> {
22
24
  this.proxyScenario = config?.proxy?.scenario;
23
25
  this.proxyRecordOnMiss = config?.proxy?.recordOnMiss ?? false;
24
26
  this.clientId = config?.clientId;
27
+ this.deviceId = config?.deviceId;
25
28
  }
26
29
 
27
30
  protected async performRequest<D = any>(config: HTTPRequestConfig<D>): Promise<HTTPResponse<any>> {
@@ -77,11 +80,13 @@ export class FetchHTTPClient extends BaseHTTPClient<any, HTTPResponse<any>> {
77
80
  headers: {
78
81
  'content-type': 'application/json',
79
82
  ...(this.clientId ? { 'x-mockifyer-client-id': this.clientId } : {}),
83
+ ...(this.deviceId ? { 'x-mockifyer-device-id': this.deviceId } : {}),
80
84
  },
81
85
  body: JSON.stringify({
82
86
  url,
83
87
  method: requestConfig.method,
84
88
  clientId: this.clientId,
89
+ deviceId: this.deviceId,
85
90
  headers: (() => {
86
91
  const out: Record<string, string> = {};
87
92
  headers.forEach((value, key) => {
package/src/index.ts CHANGED
@@ -148,6 +148,7 @@ class MockifyerClass {
148
148
  defaultHeaders: config.defaultHeaders,
149
149
  proxy: config.proxy,
150
150
  clientId: this.config.clientId,
151
+ deviceId: (this.config as any).deviceId,
151
152
  });
152
153
 
153
154
  if(!config.recordSameEndpoints) {