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

Merge pull request #3008 from Steve-Mcl/node-red-typings-update

Node red typings update
This commit is contained in:
Nick O'Leary 2021-06-08 10:29:03 +01:00 committed by GitHub
commit bd00c728d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 18 deletions

View File

@ -570,6 +570,7 @@ RED.editor.codeEditor.monaco = (function() {
createMonacoCompletionItem("set (flow context)", 'flow.set("${1:name}", ${1:value});','Set a value in flow context',range),
createMonacoCompletionItem("get (global context)", 'global.get("${1:name}");','Get a value from global context',range),
createMonacoCompletionItem("set (global context)", 'global.set("${1:name}", ${1:value});','Set a value in global context',range),
createMonacoCompletionItem("get (env)", 'env.get("${1:name}");','Get env variable value',range),
createMonacoCompletionItem("cloneMessage (RED.util)", 'RED.util.cloneMessage(${1:msg});',
["```typescript",
"RED.util.cloneMessage<T extends registry.NodeMessage>(msg: T): T",

View File

@ -1,15 +1,18 @@
/* NOTE: Do not edit directly! This file is generated using \`npm run update-types\` in https://github.com/Steve-Mcl/monaco-editor-esm-i18n */
interface NodeMessage {
topic?: string;
payload?: any;
_msgid?: string;
[other: any]: any; //permit other properties
[other: string]: any; //permit other properties
}
/** @type {NodeMessage} the `msg` object */
var msg: NodeMessage;
declare var msg: NodeMessage;
/** @type {string} the id of the incoming `msg` (alias of msg._msgid) */
const __msgid__:string;
declare const __msgid__:string;
/**
* @typedef NodeStatus
@ -46,11 +49,11 @@ declare class node {
* ```
* @see node-red documentation [writing-functions: sending messages asynchronously](https://nodered.org/docs/user-guide/writing-functions#sending-messages-asynchronously)
*/
static send(msg:object, clone:Boolean=true);
static send(msg:object, clone?:Boolean);
/** Inform runtime this instance has completed its operation */
static done();
/** Send an error to the console and debug side bar. Include `msg` in the 2nd parameter to trigger the catch node. */
static error(err:string|Error, msg:object=null);
static error(err:string|Error, msg?:object);
/** Log a warn message to the console and debug sidebar */
static warn(warning:string|Object);
/** Log an info message to the console (not sent to sidebar)' */
@ -69,33 +72,37 @@ declare class node {
*/
static status(status:NodeStatus);
/** the id of this node */
public static readonly id:string;
public readonly id:string;
/** the name of this node */
public static readonly name:string;
public readonly name:string;
/** the number of outputs of this node */
public static readonly outputCount:Number;
public readonly outputCount:Number;
}
declare class context {
/** Get a value from context */
static get(name:string, store:string="default");
static get(name:string, store?:string);
/** Store a value in context */
static set(name:string, value:Any, store:string="default");
static set(name:string, value:any, store?:string);
/** Get an array of the keys in the context store */
static keys(store:string="default"):Array ;
static keys(store?:string):Array<string> ;
}
declare class flow {
/** Get a value from flow context */
static get(name:string, store:string="default");
static get(name:string, store?:string);
/** Store a value in flow context */
static set(name:string, value:Any, store:string="default");
static set(name:string, value:any, store?:string);
/** Get an array of the keys in the flow context store */
static keys(store:string="default"):Array ;
static keys(store?:string):Array<string> ;
}
declare class global {
/** Get a value from global context */
static get(name:string, store:string="default");
static get(name:string, store?:string);
/** Store a value in global context */
static set(name:string, value:Any, store:string="default");
static set(name:string, value:any, store?:string);
/** Get an array of the keys in the global context store */
static keys(store:string="default"):Array ;
static keys(store?:string):Array<string> ;
}
declare class env {
/** Get an environment variable value */
static get(name:string);
}

View File

@ -1,4 +1,7 @@
/* NOTE: Do not edit directly! This file is generated using \`npm run update-types\` in https://github.com/Steve-Mcl/monaco-editor-esm-i18n */
/*
How to generate...
1. Generate from packages\node_modules\@node-red\util\lib\util.js using `npx typescript` and a tsconfig.json of...
@ -22,7 +25,7 @@ declare namespace RED {
/**
* Utility functions for the node-red function sandbox
*/
declare namespace util {
namespace util {
/**
* Encode an object to JSON without losing information about non-JSON types