@busy-hour/blaze
Advanced tools
Comparing version 3.1.0 to 3.1.1
@@ -5,2 +5,10 @@ # Changelog | ||
## [3.1.1](https://github.com/Busy-Hour-Studio/blaze/compare/v3.1.0...v3.1.1) (2024-05-16) | ||
### Bug Fixes | ||
* action after hooks return type ([4267789](https://github.com/Busy-Hour-Studio/blaze/commit/4267789bff55069e30159289c4c123285655c8a0)) | ||
* remove zod open api warning ([ad64fde](https://github.com/Busy-Hour-Studio/blaze/commit/ad64fde275517178d9efd962c4344568b80eb2f2)) | ||
## [3.1.0](https://github.com/Busy-Hour-Studio/blaze/compare/v3.0.3...v3.1.0) (2024-05-09) | ||
@@ -7,0 +15,0 @@ |
@@ -37,2 +37,4 @@ "use strict"; | ||
getRunTime() { | ||
if (process.versions.bun) | ||
return import_constant.PossibleRunTime.Other; | ||
if (process.versions.node) | ||
@@ -39,0 +41,0 @@ return import_constant.PossibleRunTime.Node; |
@@ -26,12 +26,12 @@ "use strict"; | ||
static info(...args) { | ||
console.log(`\x1B[0m[Blaze - LOG] `, ...args); | ||
console.log(`\x1B[0m[Blaze - LOG] `, ...args, "\x1B[0m"); | ||
} | ||
static error(...args) { | ||
console.error(`\x1B[31m[Blaze - ERROR] `, ...args); | ||
console.error(`\x1B[31m[Blaze - ERROR] `, ...args, "\x1B[0m"); | ||
} | ||
static warn(...args) { | ||
console.warn(`\x1B[33m[Blaze - WARN] `, ...args); | ||
console.warn(`\x1B[33m[Blaze - WARN] `, ...args, "\x1B[0m"); | ||
} | ||
static debug(...args) { | ||
console.debug(`\x1B[34m[Blaze - DEBUG] `, ...args); | ||
console.debug(`\x1B[34m[Blaze - DEBUG] `, ...args, "\x1B[0m"); | ||
} | ||
@@ -38,0 +38,0 @@ } |
@@ -24,2 +24,3 @@ "use strict"; | ||
BlazeError: () => import_BlazeError.BlazeError, | ||
BlazeRouter: () => import_router.BlazeRouter, | ||
initializeServices: () => import_setup.initializeServices, | ||
@@ -39,4 +40,5 @@ z: () => import_router.z | ||
BlazeError, | ||
BlazeRouter, | ||
initializeServices, | ||
z | ||
}); |
@@ -65,8 +65,8 @@ "use strict"; | ||
this.fetch = this.router.fetch.bind(this.router); | ||
if (options.path) { | ||
this.load({ | ||
path: options.path, | ||
autoStart: options.autoStart | ||
}); | ||
} | ||
if (!options.path) | ||
return; | ||
this.load({ | ||
path: options.path, | ||
autoStart: options.autoStart | ||
}); | ||
} | ||
@@ -118,3 +118,3 @@ /** | ||
const config = { | ||
fetch: this.router.fetch, | ||
fetch: this.fetch, | ||
port | ||
@@ -138,3 +138,3 @@ }; | ||
} | ||
return this.router.fetch; | ||
return this.fetch; | ||
} | ||
@@ -141,0 +141,0 @@ } |
@@ -50,6 +50,4 @@ "use strict"; | ||
this.on(route.method, route.path, route.handler); | ||
if (!this.openAPIRegistry) { | ||
import_Logger.Logger.warn(`Please install "${import_constant.ExternalModule.ZodApi}" to use OpenAPI.`); | ||
if (!this.openAPIRegistry) | ||
return; | ||
} | ||
this.openAPIRegistry.registerPath(newRoute); | ||
@@ -56,0 +54,0 @@ } |
@@ -26,3 +26,2 @@ "use strict"; | ||
var import_config = require("../config"); | ||
var import_BlazeError = require("../errors/BlazeError"); | ||
var import_Logger = require("../errors/Logger"); | ||
@@ -35,4 +34,3 @@ var import_constant = require("../utils/constant"); | ||
import_zod.z.ZodType.prototype.openapi = () => { | ||
import_Logger.Logger.error(`${import_constant.ExternalModule.ZodApi} is not installed`); | ||
throw new import_BlazeError.BlazeError(`${import_constant.ExternalModule.ZodApi} is not installed`); | ||
import_Logger.Logger.warn(`Please install "${import_constant.ExternalModule.ZodApi}" to use OpenAPI.`); | ||
}; | ||
@@ -39,0 +37,0 @@ } |
@@ -15,2 +15,4 @@ // src/config/BlazeDependency.ts | ||
getRunTime() { | ||
if (process.versions.bun) | ||
return PossibleRunTime.Other; | ||
if (process.versions.node) | ||
@@ -17,0 +19,0 @@ return PossibleRunTime.Node; |
// src/errors/Logger.ts | ||
var Logger = class { | ||
static info(...args) { | ||
console.log(`\x1B[0m[Blaze - LOG] `, ...args); | ||
console.log(`\x1B[0m[Blaze - LOG] `, ...args, "\x1B[0m"); | ||
} | ||
static error(...args) { | ||
console.error(`\x1B[31m[Blaze - ERROR] `, ...args); | ||
console.error(`\x1B[31m[Blaze - ERROR] `, ...args, "\x1B[0m"); | ||
} | ||
static warn(...args) { | ||
console.warn(`\x1B[33m[Blaze - WARN] `, ...args); | ||
console.warn(`\x1B[33m[Blaze - WARN] `, ...args, "\x1B[0m"); | ||
} | ||
static debug(...args) { | ||
console.debug(`\x1B[34m[Blaze - DEBUG] `, ...args); | ||
console.debug(`\x1B[34m[Blaze - DEBUG] `, ...args, "\x1B[0m"); | ||
} | ||
@@ -15,0 +15,0 @@ }; |
@@ -5,3 +5,3 @@ // src/index.ts | ||
import { BlazeError } from "./errors/BlazeError.js"; | ||
import { Blaze, z } from "./router/index.js"; | ||
import { Blaze, BlazeRouter, z } from "./router/index.js"; | ||
import { initializeServices } from "./utils/setup.js"; | ||
@@ -12,4 +12,5 @@ export { | ||
BlazeError, | ||
BlazeRouter, | ||
initializeServices, | ||
z | ||
}; |
@@ -33,8 +33,8 @@ // src/router/Blaze.ts | ||
this.fetch = this.router.fetch.bind(this.router); | ||
if (options.path) { | ||
this.load({ | ||
path: options.path, | ||
autoStart: options.autoStart | ||
}); | ||
} | ||
if (!options.path) | ||
return; | ||
this.load({ | ||
path: options.path, | ||
autoStart: options.autoStart | ||
}); | ||
} | ||
@@ -86,3 +86,3 @@ /** | ||
const config = { | ||
fetch: this.router.fetch, | ||
fetch: this.fetch, | ||
port | ||
@@ -106,3 +106,3 @@ }; | ||
} | ||
return this.router.fetch; | ||
return this.fetch; | ||
} | ||
@@ -109,0 +109,0 @@ }; |
@@ -28,6 +28,4 @@ // src/router/BlazeRouter.ts | ||
this.on(route.method, route.path, route.handler); | ||
if (!this.openAPIRegistry) { | ||
Logger.warn(`Please install "${ExternalModule.ZodApi}" to use OpenAPI.`); | ||
if (!this.openAPIRegistry) | ||
return; | ||
} | ||
this.openAPIRegistry.registerPath(newRoute); | ||
@@ -34,0 +32,0 @@ } |
// src/router/validator.ts | ||
import { z } from "zod"; | ||
import { BlazeDependency } from "../config/index.js"; | ||
import { BlazeError } from "../errors/BlazeError.js"; | ||
import { Logger } from "../errors/Logger.js"; | ||
@@ -12,4 +11,3 @@ import { ExternalModule } from "../utils/constant.js"; | ||
z.ZodType.prototype.openapi = () => { | ||
Logger.error(`${ExternalModule.ZodApi} is not installed`); | ||
throw new BlazeError(`${ExternalModule.ZodApi} is not installed`); | ||
Logger.warn(`Please install "${ExternalModule.ZodApi}" to use OpenAPI.`); | ||
}; | ||
@@ -16,0 +14,0 @@ } |
import type { ZodObject, ZodRawShape } from 'zod'; | ||
import type { Action, ActionValidator } from '../types/action'; | ||
import type { RecordUnknown } from '../types/helper'; | ||
export declare function createActionValidator<Header extends ZodObject<ZodRawShape>, Body extends ZodObject<ZodRawShape>, Params extends ZodObject<ZodRawShape>>(validator: ActionValidator<Header, Body, Params>): ActionValidator<Header, Body, Params>; | ||
export declare function createAction<Result, Meta extends RecordUnknown, Header extends ZodObject<ZodRawShape>, Body extends ZodObject<ZodRawShape>, Params extends ZodObject<ZodRawShape>>(action: Action<Result, Meta, Header, Body, Params>): Action<Result, Meta, Header, Body, Params, Header["_output"], Body["_output"], Params["_output"]>; | ||
export declare function createActionValidator<H extends ZodObject<ZodRawShape>, B extends ZodObject<ZodRawShape>, P extends ZodObject<ZodRawShape>>(validator: ActionValidator<H, B, P>): ActionValidator<H, B, P>; | ||
export declare function createAction<R, HR, M extends RecordUnknown, H extends ZodObject<ZodRawShape>, B extends ZodObject<ZodRawShape>, P extends ZodObject<ZodRawShape>>(action: Action<R, HR, M, H, B, P>): Action<R, HR, M, H, B, P, import("..").AcceptedAfterHook<HR, M, B["_output"], P["_output"], H["_output"]>, import("..").AcceptedBeforeHook<M, B["_output"], P["_output"], H["_output"]>, H["_output"], B["_output"], P["_output"]>; |
@@ -5,2 +5,2 @@ import type { ZodObject, ZodRawShape } from 'zod'; | ||
export declare function createEventValidator<Params extends ZodObject<ZodRawShape>>(validator: Params): Params; | ||
export declare function createEvent<Meta extends RecordUnknown, Params extends ZodObject<ZodRawShape>>(event: Event<Meta, Params>): Event<Meta, Params, Params["_output"]>; | ||
export declare function createEvent<M extends RecordUnknown, P extends ZodObject<ZodRawShape>>(event: Event<M, P>): Event<M, P, P["_output"]>; |
import type { RecordString, RecordUnknown } from '../types/helper'; | ||
import type { AfterHookHandler, BeforeHookHandler } from '../types/hooks'; | ||
export declare function createAfterHook<Meta extends RecordUnknown, Body extends RecordUnknown, Params extends RecordUnknown, Header extends RecordString, Result>(hook: AfterHookHandler<Meta, Body, Params, Header, Result>): AfterHookHandler<Meta, Body, Params, Header, Result>; | ||
export declare function createBeforeHook<Meta extends RecordUnknown, Body extends RecordUnknown, Params extends RecordUnknown, Header extends RecordString>(hook: BeforeHookHandler<Meta, Body, Params, Header>): BeforeHookHandler<Meta, Body, Params, Header>; | ||
export declare function createAfterHook<R, M extends RecordUnknown, B extends RecordUnknown, P extends RecordUnknown, H extends RecordString>(hook: AfterHookHandler<R, M, B, P, H>): AfterHookHandler<R, M, B, P, H>; | ||
export declare function createBeforeHook<M extends RecordUnknown, B extends RecordUnknown, P extends RecordUnknown, H extends RecordString>(hook: BeforeHookHandler<M, B, P, H>): BeforeHookHandler<M, B, P, H>; |
@@ -0,2 +1,4 @@ | ||
import { Actions } from '../types/action'; | ||
import { Events } from '../types/event'; | ||
import type { Service } from '../types/service'; | ||
export declare function createService(service: Service): Service<string, import("..").Actions, import("..").Events>; | ||
export declare function createService<N extends string, A extends Actions, E extends Events, S extends Service<N, A, E>>(service: S): S; |
import type { ActionCallResult as Result } from '../types/action'; | ||
import type { ActionCallRecord, ActionEventCallRequest, EventCallRecord } from '../types/common'; | ||
import type { EventName } from '../types/event'; | ||
import type { Random, RecordString, RecordUnknown } from '../types/helper'; | ||
export declare class BlazeBroker { | ||
hasListener(eventName: EventName): boolean; | ||
private validateEventName; | ||
call<T extends keyof ActionCallRecord | (string & NonNullable<unknown>), U extends ActionEventCallRequest = ActionCallRecord[T], V = Result<U['result']>>(eventName: T, body: U['body']): Promise<V>; | ||
call<T extends keyof ActionCallRecord | (string & NonNullable<unknown>), U extends ActionEventCallRequest = ActionCallRecord[T], V = Result<U['result']>>(eventName: T, body: U['body'], params: U['params']): Promise<V>; | ||
call<T extends keyof ActionCallRecord | (string & NonNullable<unknown>), U extends ActionEventCallRequest = ActionCallRecord[T], V = Result<U['result']>>(eventName: T, body: U['body'], params: U['params'], headers: U['headers']): Promise<V>; | ||
emit<T extends keyof ActionCallRecord | (string & NonNullable<unknown>), U extends ActionEventCallRequest = ActionCallRecord[T]>(eventName: T, body: U['body']): boolean; | ||
emit<T extends keyof ActionCallRecord | (string & NonNullable<unknown>), U extends ActionEventCallRequest = ActionCallRecord[T]>(eventName: T, body: U['body'], params: U['params']): boolean; | ||
emit<T extends keyof ActionCallRecord | (string & NonNullable<unknown>), U extends ActionEventCallRequest = ActionCallRecord[T]>(eventName: T, body: U['body'], params: U['params'], headers: U['headers']): boolean; | ||
event<T extends keyof EventCallRecord | (string & NonNullable<unknown>), U extends ActionEventCallRequest = EventCallRecord[T]>(eventName: T, body: U['body']): boolean; | ||
call<T extends keyof ActionCallRecord | (string & NonNullable<unknown>), U extends ActionEventCallRequest<RecordString, RecordUnknown, Random, Random> = ActionCallRecord[T], V = Result<U['result']>>(eventName: T, body: U['body']): Promise<V>; | ||
call<T extends keyof ActionCallRecord | (string & NonNullable<unknown>), U extends ActionEventCallRequest<RecordString, RecordUnknown, Random, Random> = ActionCallRecord[T], V = Result<U['result']>>(eventName: T, body: U['body'], params: U['params']): Promise<V>; | ||
call<T extends keyof ActionCallRecord | (string & NonNullable<unknown>), U extends ActionEventCallRequest<RecordString, RecordUnknown, Random, Random> = ActionCallRecord[T], V = Result<U['result']>>(eventName: T, body: U['body'], params: U['params'], headers: U['headers']): Promise<V>; | ||
emit<T extends keyof ActionCallRecord | (string & NonNullable<unknown>), U extends ActionEventCallRequest<RecordString, RecordUnknown, Random, Random> = ActionCallRecord[T]>(eventName: T, body: U['body']): boolean; | ||
emit<T extends keyof ActionCallRecord | (string & NonNullable<unknown>), U extends ActionEventCallRequest<RecordString, RecordUnknown, Random, Random> = ActionCallRecord[T]>(eventName: T, body: U['body'], params: U['params']): boolean; | ||
emit<T extends keyof ActionCallRecord | (string & NonNullable<unknown>), U extends ActionEventCallRequest<RecordString, RecordUnknown, Random, Random> = ActionCallRecord[T]>(eventName: T, body: U['body'], params: U['params'], headers: U['headers']): boolean; | ||
event<T extends keyof EventCallRecord | (string & NonNullable<unknown>), U extends ActionEventCallRequest<RecordString, RecordUnknown, Random, Random> = EventCallRecord[T]>(eventName: T, body: U['body']): boolean; | ||
} |
import './types/validator'; | ||
export type { Action, ActionHandler, ActionOpenAPI, ActionValidator, Actions, OpenAPIBody, } from './types/action'; | ||
export type { Action, ActionCallResult, ActionHandler, ActionOpenAPI, ActionValidator, Actions, AnyAction, AnyValidator, OpenAPIBody, } from './types/action'; | ||
export type { ActionCallRecord, ActionEventCallRequest, EventCallRecord, } from './types/common'; | ||
export type { Event, Events } from './types/event'; | ||
export type { AcceptedAfterHook, AcceptedBeforeHook, ActionHook, } from './types/hooks'; | ||
export type { AnyEvent, Event, Events } from './types/event'; | ||
export type { AcceptedAfterHook, AcceptedBeforeHook, ActionHook, AfterHookHandler, AnyActionHook, AnyAfterHook, AnyAfterHookHandler, AnyBeforeHook, AnyBeforeHookHandler, BeforeHookHandler, } from './types/hooks'; | ||
export type { Method, RestParam, RestRoute } from './types/rest'; | ||
@@ -10,3 +10,3 @@ export type { Service } from './types/service'; | ||
export { BlazeError } from './errors/BlazeError'; | ||
export { Blaze, z } from './router'; | ||
export { Blaze, BlazeRouter, z } from './router'; | ||
export { initializeServices } from './utils/setup'; |
import type { ResponseConfig } from '@asteasolutions/zod-to-openapi'; | ||
import type { ZodObject, ZodRawShape } from 'zod'; | ||
import type { z, ZodObject, ZodRawShape } from 'zod'; | ||
import type { BlazeContext } from '../event'; | ||
import type { Random, RecordString, RecordUnknown } from './helper'; | ||
import type { ActionHook } from './hooks'; | ||
import type { AcceptedAfterHook, AcceptedBeforeHook, ActionHook } from './hooks'; | ||
import type { RestParam } from './rest'; | ||
@@ -24,3 +24,3 @@ export interface ActionValidator<Body extends ZodObject<ZodRawShape> = ZodObject<ZodRawShape>, Params extends ZodObject<ZodRawShape> = ZodObject<ZodRawShape>, Header extends ZodObject<ZodRawShape> = ZodObject<ZodRawShape>> { | ||
} | ||
export interface Action<Result = unknown | void, Meta extends RecordUnknown = RecordUnknown, Header extends ZodObject<ZodRawShape> = ZodObject<ZodRawShape>, Body extends ZodObject<ZodRawShape> = ZodObject<ZodRawShape>, Params extends ZodObject<ZodRawShape> = ZodObject<ZodRawShape>, FinalHeader extends RecordString = Header['_output'], FinalBody extends RecordUnknown = Body['_output'], FinalParams extends RecordUnknown = Params['_output']> { | ||
export interface Action<Result = unknown | void, HookResult = unknown | void, Meta extends RecordUnknown = RecordUnknown, Header extends ZodObject<ZodRawShape> = ZodObject<ZodRawShape>, Body extends ZodObject<ZodRawShape> = ZodObject<ZodRawShape>, Params extends ZodObject<ZodRawShape> = ZodObject<ZodRawShape>, AfterHook extends AcceptedAfterHook<HookResult, Meta, Body['_output'], Params['_output'], Header['_output']> = AcceptedAfterHook<HookResult, Meta, Body['_output'], Params['_output'], Header['_output']>, BeforeHook extends AcceptedBeforeHook<Meta, Body['_output'], Params['_output'], Header['_output']> = AcceptedBeforeHook<Meta, Body['_output'], Params['_output'], Header['_output']>, FinalHeader extends RecordString = Header['_output'], FinalBody extends RecordUnknown = Body['_output'], FinalParams extends RecordUnknown = Params['_output']> { | ||
openapi?: ActionOpenAPI | null; | ||
@@ -31,3 +31,3 @@ validator?: ActionValidator<Body, Params, Header> | null; | ||
rest?: RestParam | null; | ||
hooks?: ActionHook<Meta, FinalBody, FinalParams, FinalHeader, never> | null; | ||
hooks?: ActionHook<BeforeHook, AfterHook> | null; | ||
throwOnValidationError?: boolean | null; | ||
@@ -42,5 +42,6 @@ } | ||
}; | ||
export type AnyAction = Action<Random, RecordUnknown, Random, Random, Random>; | ||
export type AnyAction = Action<Random, Random, RecordUnknown, Random, Random, Random>; | ||
export type AnyValidator = ActionValidator<z.ZodObject<z.ZodRawShape>, z.ZodObject<z.ZodRawShape>, z.ZodObject<z.ZodRawShape>>; | ||
export interface Actions { | ||
[key: string]: AnyAction; | ||
} |
import type ZodApi from '@asteasolutions/zod-to-openapi'; | ||
import type NodeServer from '@hono/node-server'; | ||
import { ExternalModule } from '../utils/constant'; | ||
import type { ExternalModule } from '../utils/constant'; | ||
export interface DependencyModule { | ||
@@ -5,0 +5,0 @@ [ExternalModule.NodeAdapter]: typeof NodeServer | null; |
@@ -5,4 +5,4 @@ import type { ZodObject, ZodRawShape } from 'zod'; | ||
import type { RecordString, RecordUnknown } from './helper'; | ||
import type { AfterHookHandler, BeforeHookHandler } from './hooks'; | ||
import { Service } from './service'; | ||
import type { AcceptedAfterHook, AcceptedBeforeHook, AfterHookHandler, BeforeHookHandler } from './hooks'; | ||
import type { Service } from './service'; | ||
export interface BlazeActionCreator { | ||
@@ -21,3 +21,3 @@ /** | ||
*/ | ||
<Result, Meta extends RecordUnknown, Header extends ZodObject<ZodRawShape>, Body extends ZodObject<ZodRawShape>, Params extends ZodObject<ZodRawShape>>(action: Action<Result, Meta, Header, Body, Params>): Action<Result, Meta, Header, Body, Params>; | ||
<R, HR, M extends RecordUnknown, H extends ZodObject<ZodRawShape>, B extends ZodObject<ZodRawShape>, P extends ZodObject<ZodRawShape>, AH extends AcceptedAfterHook<HR, M, H['_output'], B['_output'], P['_output']>, BH extends AcceptedBeforeHook<M, H['_output'], B['_output'], P['_output']>>(action: Action<R, HR, M, H, B, P, AH, BH>): Action<R, HR, M, H, B, P, AH, BH>; | ||
/** | ||
@@ -34,3 +34,3 @@ * Create a reuseable validator for actions body, params and headers. | ||
*/ | ||
validator<Header extends ZodObject<ZodRawShape>, Body extends ZodObject<ZodRawShape>, Params extends ZodObject<ZodRawShape>>(validator: ActionValidator<Header, Body, Params>): ActionValidator<Header, Body, Params>; | ||
validator<H extends ZodObject<ZodRawShape>, B extends ZodObject<ZodRawShape>, P extends ZodObject<ZodRawShape>>(validator: ActionValidator<H, B, P>): ActionValidator<H, B, P>; | ||
/** | ||
@@ -69,3 +69,3 @@ * Create an openai spec for action. | ||
*/ | ||
after<Meta extends RecordUnknown, Body extends RecordUnknown, Params extends RecordUnknown, Header extends RecordString, Result>(hook: AfterHookHandler<Meta, Body, Params, Header, Result>): AfterHookHandler<Meta, Body, Params, Header, never>; | ||
after<R, M extends RecordUnknown, B extends RecordUnknown, P extends RecordUnknown, H extends RecordString>(hook: AfterHookHandler<R, M, B, P, H>): AfterHookHandler<R, M, B, P, H>; | ||
/** | ||
@@ -83,3 +83,3 @@ * Create a reuseable before hook for the service. | ||
*/ | ||
before<Meta extends RecordUnknown, Body extends RecordUnknown, Params extends RecordUnknown, Header extends RecordString>(hook: BeforeHookHandler<Meta, Body, Params, Header>): BeforeHookHandler<Meta, Body, Params, Header>; | ||
before<M extends RecordUnknown, B extends RecordUnknown, P extends RecordUnknown, H extends RecordString>(hook: BeforeHookHandler<M, B, P, H>): BeforeHookHandler<M, B, P, H>; | ||
}; | ||
@@ -101,3 +101,3 @@ } | ||
*/ | ||
<Meta extends RecordUnknown, Params extends ZodObject<ZodRawShape>>(event: Event<Meta, Params>): Event<Meta, Params>; | ||
<M extends RecordUnknown, P extends ZodObject<ZodRawShape>>(event: Event<M, P>): Event<M, P>; | ||
/** | ||
@@ -104,0 +104,0 @@ * Create a reuseable validator for events parameters. |
import type { BlazeContext } from '../event'; | ||
import type { RecordString, RecordUnknown } from './helper'; | ||
import type { Random, RecordString, RecordUnknown } from './helper'; | ||
export interface BeforeHookHandler<Meta extends RecordUnknown = RecordUnknown, Body extends RecordUnknown = RecordUnknown, Params extends RecordUnknown = RecordUnknown, Header extends RecordString = RecordString> { | ||
(ctx: BlazeContext<Meta, Body, Params, Header>): Promise<void> | void; | ||
} | ||
export interface AfterHookHandler<Meta extends RecordUnknown = RecordUnknown, Body extends RecordUnknown = RecordUnknown, Params extends RecordUnknown = RecordUnknown, Header extends RecordString = RecordString, Result = never> { | ||
(ctx: BlazeContext<Meta, Body, Params, Header>, res: Result): Promise<unknown | void> | unknown | void; | ||
export type AnyBeforeHookHandler = BeforeHookHandler<Random, Random, Random, Random>; | ||
export interface AfterHookHandler<Result = unknown | void, Meta extends RecordUnknown = RecordUnknown, Body extends RecordUnknown = RecordUnknown, Params extends RecordUnknown = RecordUnknown, Header extends RecordString = RecordString> { | ||
(ctx: BlazeContext<Meta, Body, Params, Header>, res: never): Promise<Result> | Result; | ||
} | ||
export type AnyAfterHookHandler = AfterHookHandler<Random, Random, Random, Random, Random>; | ||
export type AcceptedBeforeHook<Meta extends RecordUnknown = RecordUnknown, Body extends RecordUnknown = RecordUnknown, Params extends RecordUnknown = RecordUnknown, Header extends RecordString = RecordString> = BeforeHookHandler<Meta, Body, Params, Header> | BeforeHookHandler<Meta, Body, Params, Header>[]; | ||
export type AcceptedAfterHook<Meta extends RecordUnknown = RecordUnknown, Body extends RecordUnknown = RecordUnknown, Params extends RecordUnknown = RecordUnknown, Header extends RecordString = RecordString, Result = never> = AfterHookHandler<Meta, Body, Params, Header, Result> | AfterHookHandler<Meta, Body, Params, Header, Result>[]; | ||
export interface ActionHook<Meta extends RecordUnknown = RecordUnknown, Body extends RecordUnknown = RecordUnknown, Params extends RecordUnknown = RecordUnknown, Header extends RecordString = RecordString, Result = never> { | ||
before?: AcceptedBeforeHook<Meta, Body, Params, Header> | null; | ||
after?: AcceptedAfterHook<Meta, Body, Params, Header, Result> | null; | ||
export type AnyBeforeHook = AcceptedBeforeHook<Random, Random, Random, Random>; | ||
export type AcceptedAfterHook<Result = unknown | void, Meta extends RecordUnknown = RecordUnknown, Body extends RecordUnknown = RecordUnknown, Params extends RecordUnknown = RecordUnknown, Header extends RecordString = RecordString> = AfterHookHandler<Result, Meta, Body, Params, Header> | AfterHookHandler<Result, Meta, Body, Params, Header>[]; | ||
export type AnyAfterHook = AcceptedAfterHook<Random, Random, Random, Random, Random>; | ||
export interface ActionHook<BeforeHook extends AcceptedBeforeHook<Random, Random, Random, Random> = AcceptedBeforeHook, AfterHook extends AcceptedAfterHook<Random, Random, Random, Random, Random> = AcceptedAfterHook> { | ||
before?: BeforeHook | null; | ||
after?: AfterHook | null; | ||
} | ||
export interface AfterHookHandlerOption<Meta extends RecordUnknown = RecordUnknown, Body extends RecordUnknown = RecordUnknown, Params extends RecordUnknown = RecordUnknown, Header extends RecordString = RecordString, Result = never> { | ||
export type AnyActionHook = ActionHook<Random, Random>; | ||
export interface AfterHookHandlerOption<Result = unknown | void, Meta extends RecordUnknown = RecordUnknown, Body extends RecordUnknown = RecordUnknown, Params extends RecordUnknown = RecordUnknown, Header extends RecordString = RecordString> { | ||
result: unknown; | ||
hooks: AcceptedAfterHook<Meta, Body, Params, Header, Result>; | ||
hooks: AcceptedAfterHook<Result, Meta, Body, Params, Header>; | ||
blazeCtx: BlazeContext<Meta, Body, Params, Header>; | ||
@@ -19,0 +24,0 @@ } |
@@ -1,3 +0,3 @@ | ||
import { z } from 'zod'; | ||
import { Random, RecordUnknown } from './helper'; | ||
import type { z } from 'zod'; | ||
import type { Random, RecordUnknown } from './helper'; | ||
type ExampleValue<T> = T extends Date ? string : T; | ||
@@ -4,0 +4,0 @@ export type ZodOpenAPIMetadata<T = Random, E = ExampleValue<T>> = Omit<RecordUnknown, 'example' | 'examples' | 'default'> & { |
@@ -13,8 +13,3 @@ /// <reference types="node" /> | ||
]; | ||
export declare function handleRestError(options: RestErrorHandlerOption): Response & import("hono").TypedResponse<{ | ||
errors: never; | ||
message: string; | ||
name: string; | ||
status: number; | ||
}>; | ||
export declare function handleRestError(options: RestErrorHandlerOption): Response & import("hono").TypedResponse<never, StatusCode, "json">; | ||
export declare function handleRestResponse(options: RestResponseHandlerOption): Response | Promise<Response>; |
@@ -10,3 +10,3 @@ import type { Event } from '../../types/event'; | ||
constructor(options: CreateEventOption); | ||
eventHandler(body: RecordUnknown, params: RecordUnknown, headers: RecordString): Promise<import("../../types/action").ActionCallResult<unknown>>; | ||
eventHandler(body: RecordUnknown, params: RecordUnknown, headers: RecordString): Promise<import("../..").ActionCallResult<unknown>>; | ||
} |
@@ -7,3 +7,3 @@ { | ||
"type": "module", | ||
"version": "3.1.0", | ||
"version": "3.1.1", | ||
"license": "MIT", | ||
@@ -10,0 +10,0 @@ "devDependencies": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
192820
4977