twd-js 1.6.2 → 1.6.4
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/bundled.es.js +57 -63
- package/dist/index.cjs.js +19 -19
- package/dist/index.d.ts +22 -0
- package/dist/index.es.js +256 -249
- package/dist/mock-sw.js +1 -1
- package/package.json +7 -7
package/dist/index.d.ts
CHANGED
|
@@ -96,26 +96,48 @@ declare type Negatable<T extends string> = T | `not.${T}`;
|
|
|
96
96
|
declare type Negatable_2<T extends string> = T | `not.${T}`;
|
|
97
97
|
|
|
98
98
|
declare interface Options {
|
|
99
|
+
/** HTTP method to match (e.g. `"GET"`, `"POST"`). */
|
|
99
100
|
method: string;
|
|
101
|
+
/** URL string or RegExp to match against the request URL. */
|
|
100
102
|
url: string | RegExp;
|
|
103
|
+
/** The mocked response body returned to the client. */
|
|
101
104
|
response: unknown;
|
|
105
|
+
/** HTTP status code for the mocked response (default: `200`). */
|
|
102
106
|
status?: number;
|
|
107
|
+
/** Headers to include in the mocked response. */
|
|
103
108
|
responseHeaders?: Record<string, string>;
|
|
109
|
+
/** Whether the `url` field should be treated as a regex pattern. */
|
|
104
110
|
urlRegex?: boolean;
|
|
111
|
+
/** Delay in milliseconds before returning the mocked response. */
|
|
105
112
|
delay?: number;
|
|
106
113
|
}
|
|
107
114
|
|
|
108
115
|
declare type Rule = {
|
|
116
|
+
/** HTTP method to match (e.g. `"GET"`, `"POST"`). */
|
|
109
117
|
method: string;
|
|
118
|
+
/** URL string or RegExp to match against the request URL. */
|
|
110
119
|
url: string | RegExp;
|
|
120
|
+
/** The mocked response body returned to the client. */
|
|
111
121
|
response: unknown;
|
|
122
|
+
/** Unique identifier for this mock rule, used with `waitForRequest`. */
|
|
112
123
|
alias: string;
|
|
124
|
+
/** Whether this rule has been matched by an actual request. Set automatically by the service worker. */
|
|
113
125
|
executed?: boolean;
|
|
126
|
+
/**
|
|
127
|
+
* The parsed request body sent by the client.
|
|
128
|
+
* For JSON requests this is the parsed object, for form data an object of key/value pairs, for text a string.
|
|
129
|
+
* Access fields directly: `rule.request.email`, **not** `rule.request.body.email`.
|
|
130
|
+
*/
|
|
114
131
|
request?: any;
|
|
132
|
+
/** HTTP status code for the mocked response (default: `200`). */
|
|
115
133
|
status?: number;
|
|
134
|
+
/** Headers to include in the mocked response. */
|
|
116
135
|
responseHeaders?: Record<string, string>;
|
|
136
|
+
/** Whether the `url` field should be treated as a regex pattern. */
|
|
117
137
|
urlRegex?: boolean;
|
|
138
|
+
/** Delay in milliseconds before returning the mocked response. */
|
|
118
139
|
delay?: number;
|
|
140
|
+
/** Number of times this rule has been matched. Updated automatically by the service worker. */
|
|
119
141
|
hitCount?: number;
|
|
120
142
|
};
|
|
121
143
|
|