@heathmont/lab-flask
Advanced tools
Comparing version 0.1.15 to 0.1.16
import 'source-map-support/register'; | ||
import { Google, Proto } from '@heathmont/coingaming-protobuf'; | ||
import { PartialBy, ProtobufMessage } from './types/types'; | ||
import { PartialBy, ProtobufMessage, ProtobufResponse, ClassInstance } from './types/types'; | ||
import { Implementations } from './implementSubstance'; | ||
@@ -44,8 +44,8 @@ import * as Long from 'long'; | ||
} | ||
export interface CallElementFunction { | ||
<REQ extends ProtobufMessage<REQ>, RESP extends ProtobufMessage<RESP>>(substanceEnum: Proto.Global.Substance, reactionEnum: Proto.Global.Element, request: REQ, responseClass: ClassInstance<RESP>, context?: Partial<LabContext>): Promise<RESP>; | ||
} | ||
export interface CallReactionFunction { | ||
<REQ extends ProtobufMessage<REQ>, RESP extends ProtobufMessage<RESP>>(substanceEnum: Proto.Global.Substance, reactionEnum: Proto.Global.Reaction, request: REQ, responseClass: any, context?: Partial<LabContext>): Promise<RESP>; | ||
<REQ extends ProtobufMessage<REQ>, RESP>(substanceEnum: Proto.Global.Substance, reactionEnum: Proto.Global.Reaction, request: REQ, responseClass: ClassInstance<RESP>, context?: Partial<LabContext>): Promise<ProtobufResponse<RESP>>; | ||
} | ||
export interface CallElementFunction { | ||
<REQ extends ProtobufMessage<REQ>, RESP extends ProtobufMessage<RESP>>(substanceEnum: Proto.Global.Substance, reactionEnum: Proto.Global.Element, request: REQ, responseClass: any, context?: Partial<LabContext>): Promise<RESP>; | ||
} | ||
export declare const init: (options: InitOptions, initDefaultContext?: PartialBy<PartialBy<LabContext, "sourceFlaskName">, "siteId">) => Promise<Lab>; | ||
@@ -52,0 +52,0 @@ declare const defaultExport: { |
import { LabConfig } from './index'; | ||
import { Proto } from '@heathmont/coingaming-protobuf'; | ||
export declare const sendRequest: <REQ extends import("./types/types").PartialBy<import("./types/types").ProtobufMessageWithToJSON<REQ>, "$type">, RESP extends import("./types/types").PartialBy<import("./types/types").ProtobufMessageWithToJSON<RESP>, "$type">>(labConfig: LabConfig, substanceEnum: Proto.Global.Substance, actKindEnum: Proto.Global.ActKind, actEnum: Proto.Global.Reaction | Proto.Global.Element, payload: REQ, responseClass: RESP, context: any) => Promise<RESP>; | ||
import { ProtobufResponse, ClassInstance } from './types/types'; | ||
export declare const sendRequest: <REQ extends import("./types/types").PartialBy<import("./types/types").ProtobufMessageWithToJSON<REQ>, "$type">, RESP>(labConfig: LabConfig, substanceEnum: Proto.Global.Substance, actKindEnum: Proto.Global.ActKind, actEnum: Proto.Global.Reaction | Proto.Global.Element, payload: REQ, responseClass: ClassInstance<RESP>, context: any) => Promise<ProtobufResponse<RESP>>; |
@@ -13,1 +13,9 @@ import { Message } from 'protobufjs'; | ||
export declare type ProtobufMessage<T extends object> = PartialBy<ProtobufMessageWithToJSON<T>, '$type'>; | ||
export declare type ProtobufResponse<T> = T & { | ||
toJSON: () => { | ||
[k: string]: unknown; | ||
}; | ||
}; | ||
export declare type ClassInstance<T> = { | ||
new (a: unknown): T; | ||
}; |
{ | ||
"name": "@heathmont/lab-flask", | ||
"version": "0.1.15", | ||
"version": "0.1.16", | ||
"author": "Margus Lamp", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
@@ -12,3 +12,3 @@ import 'source-map-support/register'; | ||
import * as bodyParser from 'body-parser'; | ||
import { PartialBy, ProtobufMessage } from './types/types'; | ||
import { PartialBy, ProtobufMessage, ProtobufResponse, ClassInstance } from './types/types'; | ||
import { Implementations, privateImplemenSubstance } from './implementSubstance'; | ||
@@ -79,18 +79,18 @@ import { longToBigNumber } from './longToBigNumber'; | ||
export interface CallReactionFunction { | ||
export interface CallElementFunction { | ||
<REQ extends ProtobufMessage<REQ>, RESP extends ProtobufMessage<RESP>> ( | ||
substanceEnum: Proto.Global.Substance, | ||
reactionEnum: Proto.Global.Reaction, | ||
reactionEnum: Proto.Global.Element, | ||
request: REQ, | ||
responseClass, | ||
responseClass: ClassInstance<RESP>, | ||
context?: Partial<LabContext>): Promise<RESP>; | ||
} | ||
export interface CallElementFunction { | ||
<REQ extends ProtobufMessage<REQ>, RESP extends ProtobufMessage<RESP>> ( | ||
export interface CallReactionFunction { | ||
<REQ extends ProtobufMessage<REQ>, RESP> ( | ||
substanceEnum: Proto.Global.Substance, | ||
reactionEnum: Proto.Global.Element, | ||
reactionEnum: Proto.Global.Reaction, | ||
request: REQ, | ||
responseClass, | ||
context?: Partial<LabContext>): Promise<RESP>; | ||
responseClass: ClassInstance<RESP>, | ||
context?: Partial<LabContext>): Promise<ProtobufResponse<RESP>>; | ||
} | ||
@@ -138,9 +138,10 @@ | ||
} | ||
const callReaction: CallReactionFunction = async <REQ extends ProtobufMessage<REQ>, RESP extends ProtobufMessage<RESP>> ( | ||
substanceEnum: Proto.Global.Substance, | ||
reactionEnum: Proto.Global.Reaction, | ||
request: REQ, | ||
const callReaction: CallReactionFunction = async( | ||
substanceEnum, | ||
reactionEnum, | ||
request, | ||
responseClass, | ||
context?: Partial<LabContext>): Promise<RESP> => { | ||
return sendRequest<REQ, RESP>( | ||
context?) => { | ||
return sendRequest( | ||
labConfig, | ||
@@ -154,8 +155,8 @@ substanceEnum, | ||
}; | ||
const callElement: CallElementFunction = async <REQ extends ProtobufMessage<REQ>, RESP extends ProtobufMessage<RESP>> ( | ||
const callElement = async <REQ extends ProtobufMessage<REQ>, RESP> ( | ||
substanceEnum: Proto.Global.Substance, | ||
reactionEnum: Proto.Global.Element, | ||
request: REQ, | ||
responseClass, | ||
context?: Partial<LabContext>): Promise<RESP> => { | ||
responseClass: ClassInstance<RESP>, | ||
context?: Partial<LabContext>): Promise<ProtobufResponse<RESP>> => { | ||
return await sendRequest<REQ, RESP>( | ||
@@ -162,0 +163,0 @@ labConfig, |
@@ -15,4 +15,3 @@ import { Proto } from '@heathmont/coingaming-protobuf'; | ||
try { | ||
const response = await callReaction<Proto.Substance.Lab.Reaction.Heartbeat.Request, | ||
Proto.Substance.Lab.Reaction.Heartbeat.Response>( | ||
const response = await callReaction( | ||
Proto.Global.Substance.LAB, | ||
@@ -19,0 +18,0 @@ Proto.Global.Reaction.HEARTBEAT, |
@@ -8,5 +8,5 @@ import { logger } from '@heathmont/node-logger'; | ||
import { createLabUrl } from './createUrls'; | ||
import { ProtobufMessage } from './types/types'; | ||
import { ProtobufMessage, ProtobufResponse, ClassInstance } from './types/types'; | ||
export const sendRequest = async <REQ extends ProtobufMessage<REQ>, RESP extends ProtobufMessage<RESP>> ( | ||
export const sendRequest = async <REQ extends ProtobufMessage<REQ>, RESP> ( | ||
labConfig: LabConfig, | ||
@@ -17,4 +17,4 @@ substanceEnum: Proto.Global.Substance, | ||
payload: REQ, | ||
responseClass: RESP, | ||
context): Promise<RESP> => { | ||
responseClass: ClassInstance<RESP>, | ||
context): Promise<ProtobufResponse<RESP>> => { | ||
const labContext = Object.assign({}, labConfig.defaultContext, context); | ||
@@ -21,0 +21,0 @@ const url = createLabUrl(labConfig, labContext, substanceEnum, actKindEnum, actEnum); |
@@ -20,1 +20,5 @@ import { Message } from 'protobufjs'; | ||
export type ProtobufMessage<T extends object> = PartialBy<ProtobufMessageWithToJSON<T>, '$type'>; | ||
export type ProtobufResponse<T> = T & { toJSON: () => { [k: string]: unknown } }; | ||
export type ClassInstance<T> = { | ||
new(a: unknown): T; | ||
}; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
99449
1763
3