11/**
22 * Mokapi JavaScript API
3- * https://mokapi.io/docs/guides/ welcome
3+ * https://mokapi.io/docs/welcome
44 */
55
66import "./faker" ;
@@ -10,6 +10,7 @@ import "./mustache";
1010import "./yaml" ;
1111import "./encoding" ;
1212import "./mail" ;
13+ import "./file" ;
1314
1415/**
1516 * Attaches an event handler for the given event.
@@ -157,6 +158,9 @@ export interface HttpRequest {
157158 /** Object contains querystring parameters specified by OpenAPI querystring parameters. */
158159 readonly querystring : any ;
159160
161+ /** Name of the API, as defined in the OpenAPI `info.title` field */
162+ readonly api : string ;
163+
160164 /** Path value specified by the OpenAPI path */
161165 readonly key : string ;
162166
@@ -183,6 +187,23 @@ export interface HttpResponse {
183187
184188 /** Data will be encoded with the OpenAPI response definition. */
185189 data : any ;
190+
191+ /**
192+ * Rebuilds the entire HTTP response using the OpenAPI response definition for the given status code and content type
193+ * @example
194+ * import { on } from 'mokapi'
195+ *
196+ * export default function() {
197+ * on('http', (request, response) => {
198+ * if (request.path.petId === 10) {
199+ * // Switch to a different OpenAPI response.
200+ * response.rebuild(404, 'application/json')
201+ * response.data.message = 'Pet not found'
202+ * }
203+ * })
204+ * }
205+ */
206+ rebuild : ( statusCode ?: number , contentType ?: string ) => void ;
186207}
187208
188209/**
@@ -421,10 +442,11 @@ export type DateLayout =
421442 | "RFC3339Nano" ;
422443
423444/**
424- * EventArgs object contains additional arguments for an event handler.
445+ * EventArgs provides optional configuration for an event handler.
425446 * https://mokapi.io/docs/javascript-api/mokapi/on
426447 *
427- * Use this to customize how the event appears in the dashboard or to control tracking.
448+ * Use this object to control how the event is tracked, labeled,
449+ * and ordered in the execution pipeline.
428450 *
429451 * @example
430452 * export default function() {
@@ -438,16 +460,32 @@ export type DateLayout =
438460 */
439461export interface EventArgs {
440462 /**
441- * Adds or overrides existing tags used to label the event in dashboard
463+ * Adds or overrides tags used to label this event in the dashboard.
464+ * Tags can be used for filtering, grouping, or ownership attribution.
442465 */
443466 tags ?: { [ key : string ] : string } ;
444467
445468 /**
446- * Set to `true` to enable tracking of this event handler in the dashboard.
447- * Set to `false` to disable tracking. If omitted, Mokapi checks the response
448- * object to determine if the handler changed it, and tracks it accordingly.
469+ * Controls whether this event handler is tracked in the dashboard.
470+ *
471+ * - true: always track this handler
472+ * - false: never track this handler
473+ * - undefined: Mokapi determines tracking automatically based on
474+ * whether the response object was modified by the handler
449475 */
450476 track ?: boolean ;
477+
478+ /**
479+ * Defines the execution order of the event handler.
480+ *
481+ * Handlers with higher priority values run first.
482+ * Handlers with lower priority values run later.
483+ *
484+ * Use negative priorities (e.g. -1) to run a handler after
485+ * the response has been fully populated by other handlers,
486+ * such as for logging or recording purposes.
487+ */
488+ priority ?: number ;
451489}
452490
453491/**
0 commit comments