Skip to main content

IOperationContext

@webda/core


Abstract Class: IOperationContext<Input, Parameters, Output>

Defined in: packages/core/src/contexts/icontext.ts:181

Abstract context for an operation, providing access to input, parameters, output, and session

Extends​

Extended by​

Type Parameters​

Input​

Input = any

Parameters​

Parameters = any

Output​

Output = any

Constructors​

Constructor​

new IOperationContext<Input, Parameters, Output>(): IOperationContext<Input, Parameters, Output>

Returns​

IOperationContext<Input, Parameters, Output>

Inherited from​

Context.constructor

Properties​

_promises​

_promises: Promise<any>[]

Defined in: packages/core/src/contexts/icontext.ts:33

Contain all registered promises to this context

Inherited from​

Context._promises


caches​

caches: any

Defined in: packages/core/src/contexts/icontext.ts:19

Get the caches linked to the context

Inherited from​

Context.caches


extensions​

protected extensions: object

Defined in: packages/core/src/contexts/icontext.ts:23

Allow extensions

Index Signature​

[key: string]: any

Inherited from​

Context.extensions


flushed​

protected flushed: boolean = false

Defined in: packages/core/src/contexts/icontext.ts:37

If the headers were flushed

Inherited from​

Context.flushed

Methods​

clearInput()​

abstract clearInput(): void

Defined in: packages/core/src/contexts/icontext.ts:202

Returns​

void


end()​

end(): Promise<void>

Defined in: packages/core/src/contexts/icontext.ts:80

Ensure the whole execution is finished

Returns​

Promise<void>

Inherited from​

Context.end


flushHeaders()​

flushHeaders(): Promise<void>

Defined in: packages/core/src/contexts/icontext.ts:134

Send the headers to the client

Returns​

Promise<void>

Inherited from​

Context.flushHeaders


getCurrentUser()​

abstract getCurrentUser(): Promise<any>

Defined in: packages/core/src/contexts/icontext.ts:90

Return the user

This method is not typed to avoid circular dependencies

Returns​

Promise<any>

Inherited from​

Context.getCurrentUser


getCurrentUserId()​

abstract getCurrentUserId(): string

Defined in: packages/core/src/contexts/icontext.ts:50

Get current user id

Returns​

string

Inherited from​

Context.getCurrentUserId


getExtension()​

getExtension<K>(name): K

Defined in: packages/core/src/contexts/icontext.ts:64

Get an extension of the context

Type Parameters​

K​

K = any

Parameters​

name​

string

of the extension

Returns​

K

extension object

Inherited from​

Context.getExtension


getInput()​

abstract getInput(): Promise<Input>

Defined in: packages/core/src/contexts/icontext.ts:185

Get the input of the context

Returns​

Promise<Input>


getOutputStream()​

abstract getOutputStream(): Promise<Writable>

Defined in: packages/core/src/contexts/icontext.ts:177

Returns​

Promise<Writable>

Inherited from​

Context.getOutputStream


getParameters()​

abstract getParameters(): Parameters

Defined in: packages/core/src/contexts/icontext.ts:206

Get the parameters of the context

Returns​

Parameters


getRawInput()​

abstract getRawInput(limit?): Promise<any>

Defined in: packages/core/src/contexts/icontext.ts:190

Get the raw input of the context

Parameters​

limit?​

number

Returns​

Promise<any>


getResponseHeaders()​

getResponseHeaders(): any

Defined in: packages/core/src/contexts/icontext.ts:127

Get current response headers

Returns​

any

the result

Inherited from​

Context.getResponseHeaders


getSession()​

abstract getSession(): any

Defined in: packages/core/src/contexts/icontext.ts:15

Get the session linked to the context if exists

Returns​

any

Inherited from​

Context.getSession


init()​

init(): Promise<IOperationContext<Input, Parameters, Output>>

Defined in: packages/core/src/contexts/icontext.ts:96

Can be used to init the context if needed Reading from the input or reaching to a db

Returns​

Promise<IOperationContext<Input, Parameters, Output>>

this for chaining

Inherited from​

Context.init


isGlobalContext()​

isGlobalContext(): boolean

Defined in: packages/core/src/contexts/icontext.ts:43

Whether this is the global (non-request-scoped) context

Returns​

boolean

true if the condition is met

Inherited from​

Context.isGlobalContext


newSession()​

abstract newSession(): any

Defined in: packages/core/src/contexts/icontext.ts:221

Create a new session

Logout the current user

Returns​

any


parameter()​

parameter(name, defaultValue?): any

Defined in: packages/core/src/contexts/icontext.ts:198

Read one specific parameter

Parameters​

name​

string

the name to use

defaultValue?​

any

the default value

Returns​

any

the result

Deprecated​

Use getParameters


pipeline()​

pipeline(stream1, ...streams): Promise<void>

Defined in: packages/core/src/contexts/icontext.ts:149

Pipeline streams into the output stream

Parameters​

stream1​

ReadableStream

the first stream

streams​

...(ReadWriteStream | PipelineOptions)[]

additional streams

Returns​

Promise<void>

See​

https://nodejs.org/api/stream.html#streampipelinestreams-options

Inherited from​

Context.pipeline


registerPromise()​

registerPromise(promise): void

Defined in: packages/core/src/contexts/icontext.ts:56

Register a promise with the context

Parameters​

promise​

any

the promise to add

Returns​

void

Inherited from​

Context.registerPromise


setExtension()​

setExtension(name, extension): this

Defined in: packages/core/src/contexts/icontext.ts:73

Parameters​

name​

string

to add

extension​

any

object to store

Returns​

this

this for chaining

Inherited from​

Context.setExtension


setHeader()​

setHeader(name, value): void

Defined in: packages/core/src/contexts/icontext.ts:104

Set a header in the response

Parameters​

name​

string

the name to use

value​

string | number | string[]

the value to set

Returns​

void

Inherited from​

Context.setHeader


setSession()​

abstract setSession(session): void

Defined in: packages/core/src/contexts/icontext.ts:214

Parameters​

session​

any

Returns​

void


write()​

abstract write(_data): boolean

Defined in: packages/core/src/contexts/icontext.ts:212

Write the output of the context

Parameters​

_data​

Output

Returns​

boolean


writeHead()​

writeHead(_code, headers): void

Defined in: packages/core/src/contexts/icontext.ts:116

For easier compatibility with WebContext On OperationContext this call is simply ignored

Parameters​

_code​

number

the status code

headers​

Returns​

void

Inherited from​

Context.writeHead