@nyth/common
Advanced tools
Comparing version 0.2.1 to 0.3.0
@@ -1,4 +0,7 @@ | ||
export { IRpcRequest, IRpcResult, IRpcExecutor, IRpcAdapter, IRpcAdapterConstructor, IRpcMethodHandler, IExecutor, IApplication, IRouting, IApplicationFactory, } from './typings'; | ||
export { BaseAdapter } from './base-adapter'; | ||
export { INTERNAL_ERROR_MESSAGE, PERMISSIONS_DENIED_MESSAGE, AppError, ScenarioError, PermissionsDeniedError, SystemError, } from './errors'; | ||
export { HandlerValidationSuccess, HANDLER_VALIDATION_SUCCESS, HandlerValidationFail, } from './handler-validation-result'; | ||
export { IHttpAdapter } from './http-adapter'; | ||
export { EScenarioStatus, IRpcResult, RpcResult, ScenarioSuccessResult, PermissionsDeniedResult, ScenarioFailResult, SystemErrorResult, } from './responses'; | ||
export { ISerializer, defaultSerializer } from './serializer'; | ||
export { BaseAdapter } from './base-adapter'; | ||
export { IRpcRequest, IRpcExecutor, IRpcAdapter, IRpcAdapterConstructor, IHandlerValidationSuccess, IHandlerValidationFail, THandlerValidationResult, IRpcMethodHandler, IExecutor, IApplication, IRouting, IApplicationFactory, } from './typings'; |
@@ -1,6 +0,7 @@ | ||
import { IRpcRequest, IRpcResult } from './typings'; | ||
import { RpcResult } from './responses'; | ||
import { IRpcRequest } from './typings'; | ||
export interface ISerializer { | ||
deserialize(req: string): IRpcRequest; | ||
serialize(res: IRpcResult): string; | ||
serialize(res: RpcResult): string; | ||
} | ||
export declare const defaultSerializer: ISerializer; |
import { BaseAdapter } from './base-adapter'; | ||
import { RpcResult } from './responses'; | ||
import { ISerializer } from './serializer'; | ||
export interface IRpcRequest<T = undefined> { | ||
export interface IRpcRequest<Payload = unknown> { | ||
readonly method: string; | ||
readonly payload: T; | ||
readonly payload: Payload; | ||
readonly correlationId?: string | number | null; | ||
readonly requestId?: string | number | null; | ||
@@ -10,6 +12,3 @@ readonly version?: number | null; | ||
} | ||
export interface IRpcResult<Payload = unknown> { | ||
readonly payload: Payload; | ||
} | ||
export type IRpcExecutor = (rpcCall: IRpcRequest) => Promise<IRpcResult>; | ||
export type IRpcExecutor = (rpcCall: IRpcRequest) => Promise<RpcResult>; | ||
export interface IRpcAdapter extends BaseAdapter { | ||
@@ -20,7 +19,16 @@ start(executor: IRpcExecutor): void | Promise<void>; | ||
export type IRpcAdapterConstructor<O = unknown> = new (options: O, serializer?: ISerializer) => IRpcAdapter; | ||
export interface IRpcMethodHandler<Result = unknown, CallData = undefined> { | ||
validate(rpcCallPayload: unknown): rpcCallPayload is CallData; | ||
export interface IHandlerValidationSuccess { | ||
readonly isValidCallData: true; | ||
readonly validationErrorMessage?: null; | ||
} | ||
export interface IHandlerValidationFail { | ||
readonly isValidCallData: false; | ||
readonly validationErrorMessage: string; | ||
} | ||
export type THandlerValidationResult = IHandlerValidationSuccess | IHandlerValidationFail; | ||
export interface IRpcMethodHandler<Result = unknown, CallData = unknown> { | ||
validate(rpcCallPayload: CallData): THandlerValidationResult; | ||
run(rpcCall: IRpcRequest<CallData>): Result | Promise<Result>; | ||
} | ||
export type IExecutor<Result = unknown, CallData = undefined> = (handler: IRpcMethodHandler<Result, CallData>) => Promise<Result>; | ||
export type IExecutor<Result = unknown, CallData = unknown> = (handler: IRpcMethodHandler<Result, CallData>) => Promise<Result>; | ||
export interface IApplication { | ||
@@ -27,0 +35,0 @@ start(): Promise<void>; |
{ | ||
"name": "@nyth/common", | ||
"version": "0.2.1", | ||
"version": "0.3.0", | ||
"description": "nyth", | ||
@@ -5,0 +5,0 @@ "author": "Andrey Sakharov <caxap_8787@mail.ru> (https://www.linkedin.com/in/andrey-sakharov/)", |
Sorry, the diff of this file is not supported yet
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
15609
18
308
1