1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Add overloads for context/flow/global set/get/keys

This commit is contained in:
Steve-Mcl 2021-06-23 22:27:13 +01:00
parent 0a8f7085f3
commit 3f27dc89d8

View File

@ -64,28 +64,201 @@ declare class node {
public readonly outputCount:number; public readonly outputCount:number;
} }
declare class context { declare class context {
/** Get a value from context */ /**
static get(name:string, store?:string); * Get one or multiple values from context (synchronous).
/** Store a value in context */ * @param name - Name of context variable
static set(name:string, value:any, store?:string); */
static get(name: string | string[]);
/**
* Get one or multiple values from context (asynchronous).
* @param name - Name (or array of names) to get from context
* @param {function} callback - (optional) Callback function (`(err,value) => {}`)
*/
static get(name: string | string[], callback: Function);
/**
* Get one or multiple values from context (synchronous).
* @param name - Name (or array of names) to get from context
* @param store - Name of context store
*/
static get(name: string | string[], store: string);
/**
* Get one or multiple values from context (asynchronous).
* @param name - Name (or array of names) to get from context
* @param store - Name of context store
* @param {function} callback - (optional) Callback function (`(err,value) => {}`)
*/
static get(name: string | string[], store: string, callback: Function);
/**
* Set one or multiple values in context (synchronous).
* @param name - Name (or array of names) to set in context
* @param value - The value (or array of values) to store in context. If the value(s) are null/undefined, the context item(s) will be removed.
*/
static set(name: string | string[], value?: any | any[]);
/**
* Set one or multiple values in context (asynchronous).
* @param name - Name (or array of names) to set in context
* @param value - The value (or array of values) to store in context. If the value(s) are null/undefined, the context item(s) will be removed.
* @param callback - (optional) Callback function (`(err) => {}`)
*/
static set(name: string | string[], value?: any | any[], callback?: Function);
/**
* Set one or multiple values in context (synchronous).
* @param name - Name (or array of names) to set in context
* @param value - The value (or array of values) to store in context. If the value(s) are null/undefined, the context item(s) will be removed.
* @param store - (optional) Name of context store
*/
static set(name: string | string[], value?: any | any[], store?: string);
/**
* Set one or multiple values in context (asynchronous).
* @param name - Name (or array of names) to set in context
* @param value - The value (or array of values) to store in context. If the value(s) are null/undefined, the context item(s) will be removed.
* @param store - (optional) Name of context store
* @param callback - (optional) Callback function (`(err) => {}`)
*/
static set(name: string | string[], value?: any | any[], store?: string, callback?: Function);
/** Get an array of the keys in the context store */ /** Get an array of the keys in the context store */
static keys(store?:string):Array<string> ; static keys(): Array<string>;
/** Get an array of the keys in the context store */
static keys(store: string): Array<string>;
/** Get an array of the keys in the context store */
static keys(callback: Function);
/** Get an array of the keys in the context store */
static keys(store: string, callback: Function);
} }
declare class flow { declare class flow {
/** Get a value from flow context */ /**
static get(name:string, store?:string); * Get one or multiple values from context (synchronous).
/** Store a value in flow context */ * @param name - Name of context variable
static set(name:string, value:any, store?:string); */
/** Get an array of the keys in the flow context store */ static get(name: string | string[]);
static keys(store?:string):Array<string> ; /**
* Get one or multiple values from context (asynchronous).
* @param name - Name (or array of names) to get from context
* @param {function} callback - (optional) Callback function (`(err,value) => {}`)
*/
static get(name: string | string[], callback: Function);
/**
* Get one or multiple values from context (synchronous).
* @param name - Name (or array of names) to get from context
* @param store - Name of context store
*/
static get(name: string | string[], store: string);
/**
* Get one or multiple values from context (asynchronous).
* @param name - Name (or array of names) to get from context
* @param store - Name of context store
* @param {function} callback - (optional) Callback function (`(err,value) => {}`)
*/
static get(name: string | string[], store: string, callback: Function);
/**
* Set one or multiple values in context (synchronous).
* @param name - Name (or array of names) to set in context
* @param value - The value (or array of values) to store in context. If the value(s) are null/undefined, the context item(s) will be removed.
*/
static set(name: string | string[], value?: any | any[]);
/**
* Set one or multiple values in context (asynchronous).
* @param name - Name (or array of names) to set in context
* @param value - The value (or array of values) to store in context. If the value(s) are null/undefined, the context item(s) will be removed.
* @param callback - (optional) Callback function (`(err) => {}`)
*/
static set(name: string | string[], value?: any | any[], callback?: Function);
/**
* Set one or multiple values in context (synchronous).
* @param name - Name (or array of names) to set in context
* @param value - The value (or array of values) to store in context. If the value(s) are null/undefined, the context item(s) will be removed.
* @param store - (optional) Name of context store
*/
static set(name: string | string[], value?: any | any[], store?: string);
/**
* Set one or multiple values in context (asynchronous).
* @param name - Name (or array of names) to set in context
* @param value - The value (or array of values) to store in context. If the value(s) are null/undefined, the context item(s) will be removed.
* @param store - (optional) Name of context store
* @param callback - (optional) Callback function (`(err) => {}`)
*/
static set(name: string | string[], value?: any | any[], store?: string, callback?: Function);
/** Get an array of the keys in the context store */
static keys(): Array<string>;
/** Get an array of the keys in the context store */
static keys(store: string): Array<string>;
/** Get an array of the keys in the context store */
static keys(callback: Function);
/** Get an array of the keys in the context store */
static keys(store: string, callback: Function);
} }
// @ts-ignore
declare class global { declare class global {
/** Get a value from global context */ /**
static get(name:string, store?:string); * Get one or multiple values from context (synchronous).
/** Store a value in global context */ * @param name - Name of context variable
static set(name:string, value:any, store?:string); */
/** Get an array of the keys in the global context store */ static get(name: string | string[]);
static keys(store?:string):Array<string> ; /**
* Get one or multiple values from context (asynchronous).
* @param name - Name (or array of names) to get from context
* @param {function} callback - (optional) Callback function (`(err,value) => {}`)
*/
static get(name: string | string[], callback: Function);
/**
* Get one or multiple values from context (synchronous).
* @param name - Name (or array of names) to get from context
* @param store - Name of context store
*/
static get(name: string | string[], store: string);
/**
* Get one or multiple values from context (asynchronous).
* @param name - Name (or array of names) to get from context
* @param store - Name of context store
* @param {function} callback - (optional) Callback function (`(err,value) => {}`)
*/
static get(name: string | string[], store: string, callback: Function);
/**
* Set one or multiple values in context (synchronous).
* @param name - Name (or array of names) to set in context
* @param value - The value (or array of values) to store in context. If the value(s) are null/undefined, the context item(s) will be removed.
*/
static set(name: string | string[], value?: any | any[]);
/**
* Set one or multiple values in context (asynchronous).
* @param name - Name (or array of names) to set in context
* @param value - The value (or array of values) to store in context. If the value(s) are null/undefined, the context item(s) will be removed.
* @param callback - (optional) Callback function (`(err) => {}`)
*/
static set(name: string | string[], value?: any | any[], callback?: Function);
/**
* Set one or multiple values in context (synchronous).
* @param name - Name (or array of names) to set in context
* @param value - The value (or array of values) to store in context. If the value(s) are null/undefined, the context item(s) will be removed.
* @param store - (optional) Name of context store
*/
static set(name: string | string[], value?: any | any[], store?: string);
/**
* Set one or multiple values in context (asynchronous).
* @param name - Name (or array of names) to set in context
* @param value - The value (or array of values) to store in context. If the value(s) are null/undefined, the context item(s) will be removed.
* @param store - (optional) Name of context store
* @param callback - (optional) Callback function (`(err) => {}`)
*/
static set(name: string | string[], value?: any | any[], store?: string, callback?: Function);
/** Get an array of the keys in the context store */
static keys(): Array<string>;
/** Get an array of the keys in the context store */
static keys(store: string): Array<string>;
/** Get an array of the keys in the context store */
static keys(callback: Function);
/** Get an array of the keys in the context store */
static keys(store: string, callback: Function);
} }
declare class env { declare class env {
/** Get an environment variable value */ /** Get an environment variable value */