go-mokapi 0.57.0 → 0.59.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "go-mokapi",
3
- "version": "0.57.0",
3
+ "version": "0.59.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.59.0",
16
+ "@go-mokapi/darwin-x64": "0.59.0",
17
+ "@go-mokapi/linux-arm64": "0.59.0",
18
+ "@go-mokapi/linux-x64": "0.59.0",
19
+ "@go-mokapi/win32-arm64": "0.59.0",
20
+ "@go-mokapi/win32-x64": "0.59.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
 
@@ -1206,7 +1226,7 @@ export interface SmtpEventArgs extends EventArgs {
1206
1226
  * export default function() {
1207
1227
  * every('1m', function() {
1208
1228
  * console.log('foo')
1209
- * }, {times: 1, runFirstTimeImmediately: false})
1229
+ * }, {times: 1, skipImmediateFirstRun: true})
1210
1230
  * }
1211
1231
  */
1212
1232
  export type ScheduledEventHandler = () => void | Promise<void>;
@@ -1227,9 +1247,11 @@ export interface ScheduledEventArgs {
1227
1247
  times?: number;
1228
1248
 
1229
1249
  /**
1230
- * Toggles behavior of first execution. Default is true
1250
+ * If true, the job does not run immediately but waits for the first
1251
+ * interval or the first match of the cron expression.
1252
+ * Default is `false` for `every` and `true` for `cron`.
1231
1253
  */
1232
- runFirstTimeImmediately?: boolean;
1254
+ skipImmediateFirstRun?: boolean;
1233
1255
  }
1234
1256
 
1235
1257
  /**
@@ -2566,7 +2588,7 @@ export interface KafkaProduceArgs {
2566
2588
  * @example
2567
2589
  * app.kafka().produce('order-placed', { data: { id: 1 } }, {
2568
2590
  * result: (r) => {
2569
- * console.log(r.cluster) // e.g. 'Order Events'
2591
+ * console.log(r.api) // e.g. 'Order Events'
2570
2592
  * console.log(r.topic) // e.g. 'order-placed'
2571
2593
  * console.log(r.messages[0].offset) // e.g. 42
2572
2594
  * }
package/types/kafka.d.ts CHANGED
@@ -182,44 +182,16 @@ export interface Message {
182
182
  * }
183
183
  */
184
184
  export interface ProduceResult {
185
- /** Name of the Kafka cluster where the messages were written. */
186
- readonly cluster: string;
185
+ /**
186
+ * Name of the Kafka cluster (AsyncAPI `info.title`) where the messages were written.
187
+ */
188
+ readonly api: string;
187
189
 
188
190
  /** Name of the Kafka topic where the messages were written. */
189
191
  readonly topic: string;
190
192
 
191
193
  /** The written messages, in the same order as in {@link ProduceArgs.messages}. */
192
194
  readonly messages: readonly MessageResult[];
193
-
194
- /**
195
- * Partition of the first written message.
196
- * @deprecated Use `messages[i].partition` instead.
197
- */
198
- readonly partition: number;
199
-
200
- /**
201
- * Offset of the first written message.
202
- * @deprecated Use `messages[i].offset` instead.
203
- */
204
- readonly offset: number;
205
-
206
- /**
207
- * Key of the first written message.
208
- * @deprecated Use `messages[i].key` instead.
209
- */
210
- readonly key: string;
211
-
212
- /**
213
- * Value of the first written message.
214
- * @deprecated Use `messages[i].value` instead.
215
- */
216
- readonly value: string;
217
-
218
- /**
219
- * Headers of the first written message.
220
- * @deprecated Use `messages[i].headers` instead.
221
- */
222
- readonly headers: { [name: string]: string };
223
195
  }
224
196
 
225
197
  /**
package/types/mqtt.d.ts CHANGED
@@ -67,22 +67,21 @@ export interface PublishArgs {
67
67
  }
68
68
 
69
69
  /**
70
- * Contains information of the written Kafka message.
71
- * https://mokapi.io/docs/javascript-api/mokapi-kafka/produceresult
70
+ * Contains information of the published MQTT message.
72
71
  * @example
73
72
  * export default function() {
74
- * const res = produce({ topic: 'foo' })
75
- * console.log(`new kafka message written with offset: ${res.offset}`)
73
+ * const res = publish({ topic: 'foo' })
74
+ * console.log(`message published to topic ${res.topic} of ${res.api}`)
76
75
  * }
77
76
  */
78
77
  export interface PublishResult {
79
- /** Name of the Kafka cluster where the message was written. */
80
- readonly cluster: string;
78
+ /** Name of the MQTT broker (AsyncAPI `info.title`) where the message was published. */
79
+ readonly api: string;
81
80
 
82
- /** Kafka topic name where the message was written. */
81
+ /** MQTT topic name where the message was published. */
83
82
  readonly topic: string;
84
83
 
85
- /** The value of the written message. */
84
+ /** The value of the published message. */
86
85
  readonly value: string;
87
86
  }
88
87