@busy-hour/blaze
Advanced tools
Comparing version 3.0.2 to 3.0.3
@@ -5,2 +5,9 @@ # Changelog | ||
## [3.0.3](https://github.com/Busy-Hour-Studio/blaze/compare/v3.0.2...v3.0.3) (2024-05-03) | ||
### Bug Fixes | ||
* creator handler return type ([f426789](https://github.com/Busy-Hour-Studio/blaze/commit/f4267898c958a01bf8cbf5b3c1762c3011e679dc)) | ||
## [3.0.2](https://github.com/Busy-Hour-Studio/blaze/compare/v3.0.1...v3.0.2) (2024-05-01) | ||
@@ -7,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> = ZodObject<ZodRawShape>, Body extends ZodObject<ZodRawShape> = ZodObject<ZodRawShape>, Params extends ZodObject<ZodRawShape> = ZodObject<ZodRawShape>>(validator: ActionValidator<Header, Body, Params>): ActionValidator<Header, Body, Params>; | ||
export declare function createAction<Meta extends RecordUnknown = RecordUnknown, Header extends ZodObject<ZodRawShape> = ZodObject<ZodRawShape>, Body extends ZodObject<ZodRawShape> = ZodObject<ZodRawShape>, Params extends ZodObject<ZodRawShape> = ZodObject<ZodRawShape>>(action: Action<Meta, Header, Body, Params>): Action<Meta, Header, Body, Params, Header["_output"] & import("../types/helper").RecordString, Body["_output"] & RecordUnknown, Params["_output"] & RecordUnknown>; | ||
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"]>; |
import type { ZodObject, ZodRawShape } from 'zod'; | ||
import type { Event } from '../types/event'; | ||
import type { RecordUnknown } from '../types/helper'; | ||
export declare function createEventValidator<Params extends ZodObject<ZodRawShape> = ZodObject<ZodRawShape>>(validator: Params): Params; | ||
export declare function createEvent<Meta extends RecordUnknown = RecordUnknown, Params extends ZodObject<ZodRawShape> = ZodObject<ZodRawShape>>(event: Event<Meta, Params>): Event<Meta, Params, Params["_output"] & RecordUnknown>; | ||
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"]>; |
import type { RecordString, RecordUnknown } from '../types/helper'; | ||
import type { AfterHookHandler, BeforeHookHandler } from '../types/hooks'; | ||
export declare function createAfterHook<Meta extends RecordUnknown = RecordUnknown, Body extends RecordUnknown = RecordUnknown, Params extends RecordUnknown = RecordUnknown, Header extends RecordString = RecordString, Result = never>(hook: AfterHookHandler<Meta, Body, Params, Header, Result>): AfterHookHandler<Meta, Body, Params, Header, Result>; | ||
export declare function createBeforeHook<Meta extends RecordUnknown = RecordUnknown, Body extends RecordUnknown = RecordUnknown, Params extends RecordUnknown = RecordUnknown, Header extends RecordString = RecordString>(hook: BeforeHookHandler<Meta, Body, Params, Header>): BeforeHookHandler<Meta, Body, Params, Header>; | ||
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>; |
import type { BlazeActionCreator, BlazeEventCreator, BlazeServiceCreator } from '../types/creator'; | ||
/** | ||
* Create Blaze service, action, event, etc. | ||
* @deprecated use "satifies Service, Action, Event, etc." instead to support type safe code with "@busy-hour/blaze-type" | ||
*/ | ||
@@ -6,0 +5,0 @@ export declare const BlazeCreator: { |
@@ -12,4 +12,4 @@ import type { ResponseConfig } from '@asteasolutions/zod-to-openapi'; | ||
} | ||
export interface ActionHandler<Meta extends RecordUnknown = RecordUnknown, Body extends RecordUnknown = RecordUnknown, Params extends RecordUnknown = RecordUnknown, Header extends RecordString = RecordString> { | ||
(ctx: BlazeContext<Meta, Body, Params, Header>): Promise<unknown | void> | unknown | void; | ||
export interface ActionHandler<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>): Promise<Result> | Result; | ||
} | ||
@@ -25,6 +25,6 @@ export interface OpenAPIBody { | ||
} | ||
export interface Action<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'] & RecordString, FinalBody extends RecordUnknown = Body['_output'] & RecordUnknown, FinalParams extends RecordUnknown = Params['_output'] & RecordUnknown> { | ||
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']> { | ||
openapi?: ActionOpenAPI | null; | ||
validator?: ActionValidator<Body, Params, Header> | null; | ||
handler: ActionHandler<Meta, FinalBody, FinalParams, FinalHeader>; | ||
handler: ActionHandler<Result, Meta, FinalBody, FinalParams, FinalHeader>; | ||
rest?: RestParam | null; | ||
@@ -42,3 +42,3 @@ hooks?: ActionHook<Meta, FinalBody, FinalParams, FinalHeader, never> | null; | ||
export interface Actions { | ||
[key: string]: Action<RecordUnknown, Random, Random, Random>; | ||
[key: string]: Action<Random, RecordUnknown, Random, Random, Random>; | ||
} |
@@ -20,3 +20,3 @@ import type { ZodObject, ZodRawShape } from 'zod'; | ||
*/ | ||
<Meta extends RecordUnknown = RecordUnknown, Header extends ZodObject<ZodRawShape> = ZodObject<ZodRawShape>, Body extends ZodObject<ZodRawShape> = ZodObject<ZodRawShape>, Params extends ZodObject<ZodRawShape> = ZodObject<ZodRawShape>>(action: Action<Meta, Header, Body, Params>): Action<Meta, Header, Body, Params>; | ||
<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>; | ||
/** | ||
@@ -33,3 +33,3 @@ * Create a reuseable validator for actions body, params and headers. | ||
*/ | ||
validator<Header extends ZodObject<ZodRawShape> = ZodObject<ZodRawShape>, Body extends ZodObject<ZodRawShape> = ZodObject<ZodRawShape>, Params extends ZodObject<ZodRawShape> = ZodObject<ZodRawShape>>(validator: ActionValidator<Header, Body, Params>): ActionValidator<Header, Body, Params>; | ||
validator<Header extends ZodObject<ZodRawShape>, Body extends ZodObject<ZodRawShape>, Params extends ZodObject<ZodRawShape>>(validator: ActionValidator<Header, Body, Params>): ActionValidator<Header, Body, Params>; | ||
/** | ||
@@ -68,3 +68,3 @@ * Create an openai spec for action. | ||
*/ | ||
after<Meta extends RecordUnknown = RecordUnknown, Body extends RecordUnknown = RecordUnknown, Params extends RecordUnknown = RecordUnknown, Header extends RecordString = RecordString, Result = never>(hook: AfterHookHandler<Meta, Body, Params, Header, Result>): AfterHookHandler<Meta, Body, Params, Header, never>; | ||
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>; | ||
/** | ||
@@ -82,3 +82,3 @@ * Create a reuseable before hook for the service. | ||
*/ | ||
before<Meta extends RecordUnknown = RecordUnknown, Body extends RecordUnknown = RecordUnknown, Params extends RecordUnknown = RecordUnknown, Header extends RecordString = RecordString>(hook: BeforeHookHandler<Meta, Body, Params, Header>): BeforeHookHandler<Meta, Body, Params, Header>; | ||
before<Meta extends RecordUnknown, Body extends RecordUnknown, Params extends RecordUnknown, Header extends RecordString>(hook: BeforeHookHandler<Meta, Body, Params, Header>): BeforeHookHandler<Meta, Body, Params, Header>; | ||
}; | ||
@@ -100,3 +100,3 @@ } | ||
*/ | ||
<Meta extends RecordUnknown = RecordUnknown, Params extends ZodObject<ZodRawShape> = ZodObject<ZodRawShape>>(event: Event<Meta, Params>): Event<Meta, Params>; | ||
<Meta extends RecordUnknown, Params extends ZodObject<ZodRawShape>>(event: Event<Meta, Params>): Event<Meta, Params>; | ||
/** | ||
@@ -112,3 +112,3 @@ * Create a reuseable validator for events parameters. | ||
*/ | ||
validator<Params extends ZodObject<ZodRawShape> = ZodObject<ZodRawShape>>(validator: Params): Params; | ||
validator<Params extends ZodObject<ZodRawShape>>(validator: Params): Params; | ||
} | ||
@@ -129,5 +129,5 @@ export interface BlazeServiceCreator { | ||
*/ | ||
(service: Service): Service; | ||
<T extends Service>(service: T): Readonly<T>; | ||
action: BlazeActionCreator; | ||
event: BlazeEventCreator; | ||
} |
@@ -16,3 +16,3 @@ import type { ZodObject, ZodRawShape } from 'zod'; | ||
} | ||
export interface Event<Meta extends RecordUnknown = RecordUnknown, Params extends ZodObject<ZodRawShape> = ZodObject<ZodRawShape>, FinalParams extends RecordUnknown = Params['_output'] & RecordUnknown> { | ||
export interface Event<Meta extends RecordUnknown = RecordUnknown, Params extends ZodObject<ZodRawShape> = ZodObject<ZodRawShape>, FinalParams extends RecordUnknown = Params['_output']> { | ||
validator?: Params | null; | ||
@@ -19,0 +19,0 @@ handler: EventHandler<Meta, FinalParams>; |
@@ -7,3 +7,3 @@ { | ||
"type": "module", | ||
"version": "3.0.2", | ||
"version": "3.0.3", | ||
"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
188895
4916