@@ -108,10 +108,6 @@ export interface EventHandler {
108108 smtp : SmtpEventHandler ;
109109}
110110
111- export type ChangeResult = boolean | undefined ;
112-
113- export type EventHandlerResult = ChangeResult | Promise < ChangeResult > ;
114-
115111/**
116112 * HttpEventHandler is a function that is executed when an HTTP event is triggered.
117113 * https://mokapi.io/docs/javascript-api/mokapi/eventhandler/httpeventhandler
@@ -126,7 +122,7 @@ export type EventHandlerResult = ChangeResult | Promise<ChangeResult>;
126122 * })
127123 * }
128124 */
129- export type HttpEventHandler = ( request : HttpRequest , response : HttpResponse ) => EventHandlerResult ;
125+ export type HttpEventHandler = ( request : HttpRequest , response : HttpResponse ) => void ;
130126
131127/**
132128 * HttpRequest is an object used by HttpEventHandler that contains request-specific
@@ -208,7 +204,7 @@ export interface Url {
208204 * })
209205 * }
210206 */
211- export type KafkaEventHandler = ( message : KafkaEventMessage ) => EventHandlerResult ;
207+ export type KafkaEventHandler = ( message : KafkaEventMessage ) => void ;
212208
213209/**
214210 * KafkaEventMessage is an object used by KafkaEventHandler that contains Kafka-specific message data.
@@ -247,7 +243,7 @@ export interface KafkaEventMessage {
247243 * })
248244 * }
249245 */
250- export type LdapEventHandler = ( request : LdapSearchRequest , response : LdapSearchResponse ) => EventHandlerResult ;
246+ export type LdapEventHandler = ( request : LdapSearchRequest , response : LdapSearchResponse ) => void ;
251247
252248/**
253249 * LdapSearchRequest is an object used by LdapEventHandler that contains request-specific data.
@@ -347,7 +343,7 @@ export enum LdapResultStatus {
347343 SizeLimitExceeded = 4 ,
348344}
349345
350- export type SmtpEventHandler = ( record : SmtpEventMessage ) => EventHandlerResult ;
346+ export type SmtpEventHandler = ( record : SmtpEventMessage ) => void ;
351347
352348export interface SmtpEventMessage {
353349 server : string ;
@@ -460,4 +456,57 @@ export interface JSONObject {
460456 [ key : string ] : JSONValue ;
461457}
462458
463- export const RFC3339 = "RFC3339" ;
459+ /**
460+ * Specifies the date-time format defined in [RFC 3339](https://datatracker.ietf.org/doc/html/rfc3339).
461+ * This constant can be used when defining or validating datetime strings.
462+ *
463+ * @example
464+ * const date = new Date().toISOString()
465+ * if (isValidDate(date, RFC3339)) {
466+ * // do something
467+ * }
468+ */
469+ export const RFC3339 = "RFC3339" ;
470+
471+ /**
472+ * Applies a patch object to a target object. Only properties that are explicitly defined in the patch
473+ * are applied. This includes nested objects. Properties marked with `Delete` will be removed.
474+ *
475+ * This function is especially useful when working with generated mock data in Mokapi that you want to override
476+ * or refine with specific values.
477+ *
478+ * https://mokapi.io/docs/javascript-api/mokapi/patch
479+ *
480+ * @param target The original object or value to be patched.
481+ * @param patch The patch object or value. Only defined values are applied; undefined values are ignored. Use `Delete` to remove fields.
482+ * @returns A new object or value with the patch applied.
483+ *
484+ * @example
485+ * const result = patch({ name: "foo", age: 42 }, { name: "bar" })
486+ * // result: { name: "bar", age: 42 }
487+ *
488+ * @example
489+ * const result = patch({ name: "foo", meta: { version: 1 } }, { meta: { version: 2 } })
490+ * // result: { name: "foo", meta: { version: 2 } }
491+ *
492+ * @example
493+ * const result = patch({ name: "foo", age: 42 }, { age: Delete })
494+ * // result: { name: "foo" }
495+ */
496+ export function patch ( target : any , patch : any ) : any ;
497+
498+ /**
499+ * Special marker used with the `patch` function to indicate a property should be removed.
500+ *
501+ * When used as a value inside a patch object, the corresponding property will be deleted
502+ * from the result.
503+ *
504+ * This is useful when refining or overriding mock data in a script while keeping validation logic intact.
505+ *
506+ * https://mokapi.io/docs/javascript-api/mokapi/patch#delete
507+ *
508+ * @example
509+ * const result = patch({ name: "foo", age: 42 }, { age: Delete })
510+ * // result: { name: "foo" }
511+ */
512+ export const Delete : unique symbol ;
0 commit comments