go-mokapi 0.57.0 → 0.58.0

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.
Files changed (2) hide show
  1. package/package.json +7 -7
  2. package/types/index.d.ts +27 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "go-mokapi",
3
- "version": "0.57.0",
3
+ "version": "0.58.0",
4
4
  "description": "Easy and flexible API mocking",
5
5
  "homepage": "https://mokapi.io",
6
6
  "repository": {
@@ -12,12 +12,12 @@
12
12
  },
13
13
  "preferUnplugged": true,
14
14
  "optionalDependencies": {
15
- "@go-mokapi/darwin-arm64": "0.57.0",
16
- "@go-mokapi/darwin-x64": "0.57.0",
17
- "@go-mokapi/linux-arm64": "0.57.0",
18
- "@go-mokapi/linux-x64": "0.57.0",
19
- "@go-mokapi/win32-arm64": "0.57.0",
20
- "@go-mokapi/win32-x64": "0.57.0"
15
+ "@go-mokapi/darwin-arm64": "0.58.0",
16
+ "@go-mokapi/darwin-x64": "0.58.0",
17
+ "@go-mokapi/linux-arm64": "0.58.0",
18
+ "@go-mokapi/linux-x64": "0.58.0",
19
+ "@go-mokapi/win32-arm64": "0.58.0",
20
+ "@go-mokapi/win32-x64": "0.58.0"
21
21
  },
22
22
  "keywords": [
23
23
  "mock api",
package/types/index.d.ts CHANGED
@@ -91,12 +91,31 @@ export function date(args?: DateArgs): string;
91
91
 
92
92
  /**
93
93
  * Suspends the execution for the specified duration.
94
+ * It blocks all handlers of the script file, use {@link delay} to delay only the calling handler.
94
95
  * https://mokapi.io/docs/javascript-api/mokapi/sleep
95
96
  * @param time Duration in milliseconds or duration as string with unit.
96
97
  * Valid time units are `ns`, `us` (or `µs`), `ms`, `s`, `m`, `h`
97
98
  */
98
99
  export function sleep(time: number | string): void;
99
100
 
101
+ /**
102
+ * Delays the calling handler for the specified duration without blocking other handlers.
103
+ * The handler must be `async` and `await` the returned `Promise`.
104
+ * https://mokapi.io/docs/javascript-api/mokapi/delay
105
+ * @param time Duration in milliseconds or duration as string with unit.
106
+ * Valid time units are `ns`, `us` (or `µs`), `ms`, `s`, `m`, `h`.
107
+ * A number with a fraction is truncated to whole milliseconds,
108
+ * zero or a negative number resolves right away.
109
+ * @returns A `Promise` that resolves after the given time.
110
+ * @example
111
+ * export default function() {
112
+ * on('http', async (request, response) => {
113
+ * await delay('500ms')
114
+ * })
115
+ * }
116
+ */
117
+ export function delay(time: number | string): Promise<void>;
118
+
100
119
  /**
101
120
  * Specifies the interval of a periodic job.
102
121
  * Interval string is a possibly signed sequence of decimal numbers, each with an optional
@@ -278,25 +297,26 @@ export interface HttpResponse {
278
297
  }
279
298
 
280
299
  /**
281
- * Represents an URL
300
+ * Represents the URL of an HTTP request.
301
+ * https://mokapi.io/docs/javascript-api/mokapi/eventhandler/httprequest
282
302
  */
283
303
  export interface Url {
284
- /** URL scheme. */
304
+ /** URL scheme: `https` if the request was received over TLS, otherwise `http`. */
285
305
  readonly scheme: string;
286
306
 
287
- /** URL host. */
307
+ /** Host name from the Host header of the request, without the port. */
288
308
  readonly host: string;
289
309
 
290
- /** URL port */
310
+ /** Port from the Host header. If missing, the port of the request URL, else 443 (https) or 80 (http). */
291
311
  readonly port: number;
292
312
 
293
- /** URL path. */
313
+ /** Decoded request path, e.g. `/pets/my pet` for `/pets/my%20pet`. */
294
314
  readonly path: string;
295
315
 
296
- /** URL query string. */
316
+ /** Raw query string without the leading `?`, e.g. `limit=10&offset=0`. */
297
317
  readonly query: string;
298
318
 
299
- /** Returns a string representing this Url object. */
319
+ /** Returns scheme, host, path and query, e.g. `http://localhost/pets?limit=10`. The port is not included. */
300
320
  toString(): string;
301
321
  }
302
322