@node-red/editor-client 1.3.3 → 1.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,266 @@
1
+
2
+ /* NOTE: Do not edit directly! This file is generated using \`npm run update-types\` in https://github.com/Steve-Mcl/monaco-editor-esm-i18n */
3
+
4
+
5
+ interface NodeMessage {
6
+ topic?: string;
7
+ payload?: any;
8
+ _msgid?: string;
9
+ [other: string]: any; //permit other properties
10
+ }
11
+
12
+ /** @type {NodeMessage} the `msg` object */
13
+ declare var msg: NodeMessage;
14
+ /** @type {string} the id of the incoming `msg` (alias of msg._msgid) */
15
+ declare const __msgid__:string;
16
+
17
+ /**
18
+ * @typedef NodeStatus
19
+ * @type {object}
20
+ * @property {string} [fill] The fill property can be: red, green, yellow, blue or grey.
21
+ * @property {string} [shape] The shape property can be: ring or dot.
22
+ * @property {string} [text] The text to display
23
+ */
24
+ interface NodeStatus {
25
+ /** The fill property can be: red, green, yellow, blue or grey */
26
+ fill?: string,
27
+ /** The shape property can be: ring or dot */
28
+ shape?: string,
29
+ /** The text to display */
30
+ text?: string|boolean|number
31
+ }
32
+
33
+ declare class node {
34
+ /**
35
+ * Send 1 or more messages asynchronously
36
+ * @param {object | object[]} msg The msg object
37
+ * @param {Boolean} [clone=true] Flag to indicate the `msg` should be cloned. Default = `true`
38
+ * @see node-red documentation [writing-functions: sending messages asynchronously](https://nodered.org/docs/user-guide/writing-functions#sending-messages-asynchronously)
39
+ */
40
+ static send(msg:object|object[], clone?:Boolean): void;
41
+ /** Inform runtime this instance has completed its operation */
42
+ static done();
43
+ /** Send an error to the console and debug side bar. Include `msg` in the 2nd parameter to trigger the catch node. */
44
+ static error(err:string|Error, msg?:object);
45
+ /** Log a warn message to the console and debug sidebar */
46
+ static warn(warning:string|object);
47
+ /** Log an info message to the console (not sent to sidebar)' */
48
+ static log(info:string|object);
49
+ /** Sets the status icon and text underneath the node.
50
+ * @param {NodeStatus} status - The status object `{fill, shape, text}`
51
+ * @see node-red documentation [writing-functions: adding-status](https://nodered.org/docs/user-guide/writing-functions#adding-status)
52
+ */
53
+ static status(status:NodeStatus);
54
+ /** Sets the status text underneath the node.
55
+ * @param {string} status - The status to display
56
+ * @see node-red documentation [writing-functions: adding-status](https://nodered.org/docs/user-guide/writing-functions#adding-status)
57
+ */
58
+ static status(status:string|boolean|number);
59
+ /** the id of this node */
60
+ public readonly id:string;
61
+ /** the name of this node */
62
+ public readonly name:string;
63
+ /** the number of outputs of this node */
64
+ public readonly outputCount:number;
65
+ }
66
+ declare class context {
67
+ /**
68
+ * Get one or multiple values from context (synchronous).
69
+ * @param name - Name of context variable
70
+ */
71
+ static get(name: string | string[]);
72
+ /**
73
+ * Get one or multiple values from context (asynchronous).
74
+ * @param name - Name (or array of names) to get from context
75
+ * @param {function} callback - (optional) Callback function (`(err,value) => {}`)
76
+ */
77
+ static get(name: string | string[], callback: Function);
78
+ /**
79
+ * Get one or multiple values from context (synchronous).
80
+ * @param name - Name (or array of names) to get from context
81
+ * @param store - Name of context store
82
+ */
83
+ static get(name: string | string[], store: string);
84
+ /**
85
+ * Get one or multiple values from context (asynchronous).
86
+ * @param name - Name (or array of names) to get from context
87
+ * @param store - Name of context store
88
+ * @param {function} callback - (optional) Callback function (`(err,value) => {}`)
89
+ */
90
+ static get(name: string | string[], store: string, callback: Function);
91
+
92
+
93
+ /**
94
+ * Set one or multiple values in context (synchronous).
95
+ * @param name - Name (or array of names) to set in context
96
+ * @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.
97
+ */
98
+ static set(name: string | string[], value?: any | any[]);
99
+ /**
100
+ * Set one or multiple values in context (asynchronous).
101
+ * @param name - Name (or array of names) to set in context
102
+ * @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.
103
+ * @param callback - (optional) Callback function (`(err) => {}`)
104
+ */
105
+ static set(name: string | string[], value?: any | any[], callback?: Function);
106
+ /**
107
+ * Set one or multiple values in context (synchronous).
108
+ * @param name - Name (or array of names) to set in context
109
+ * @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.
110
+ * @param store - (optional) Name of context store
111
+ */
112
+ static set(name: string | string[], value?: any | any[], store?: string);
113
+ /**
114
+ * Set one or multiple values in context (asynchronous).
115
+ * @param name - Name (or array of names) to set in context
116
+ * @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.
117
+ * @param store - (optional) Name of context store
118
+ * @param callback - (optional) Callback function (`(err) => {}`)
119
+ */
120
+ static set(name: string | string[], value?: any | any[], store?: string, callback?: Function);
121
+
122
+ /** Get an array of the keys in the context store */
123
+ static keys(): Array<string>;
124
+ /** Get an array of the keys in the context store */
125
+ static keys(store: string): Array<string>;
126
+ /** Get an array of the keys in the context store */
127
+ static keys(callback: Function);
128
+ /** Get an array of the keys in the context store */
129
+ static keys(store: string, callback: Function);
130
+ }
131
+ declare class flow {
132
+ /**
133
+ * Get one or multiple values from context (synchronous).
134
+ * @param name - Name of context variable
135
+ */
136
+ static get(name: string | string[]);
137
+ /**
138
+ * Get one or multiple values from context (asynchronous).
139
+ * @param name - Name (or array of names) to get from context
140
+ * @param {function} callback - (optional) Callback function (`(err,value) => {}`)
141
+ */
142
+ static get(name: string | string[], callback: Function);
143
+ /**
144
+ * Get one or multiple values from context (synchronous).
145
+ * @param name - Name (or array of names) to get from context
146
+ * @param store - Name of context store
147
+ */
148
+ static get(name: string | string[], store: string);
149
+ /**
150
+ * Get one or multiple values from context (asynchronous).
151
+ * @param name - Name (or array of names) to get from context
152
+ * @param store - Name of context store
153
+ * @param {function} callback - (optional) Callback function (`(err,value) => {}`)
154
+ */
155
+ static get(name: string | string[], store: string, callback: Function);
156
+
157
+
158
+ /**
159
+ * Set one or multiple values in context (synchronous).
160
+ * @param name - Name (or array of names) to set in context
161
+ * @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.
162
+ */
163
+ static set(name: string | string[], value?: any | any[]);
164
+ /**
165
+ * Set one or multiple values in context (asynchronous).
166
+ * @param name - Name (or array of names) to set in context
167
+ * @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.
168
+ * @param callback - (optional) Callback function (`(err) => {}`)
169
+ */
170
+ static set(name: string | string[], value?: any | any[], callback?: Function);
171
+ /**
172
+ * Set one or multiple values in context (synchronous).
173
+ * @param name - Name (or array of names) to set in context
174
+ * @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.
175
+ * @param store - (optional) Name of context store
176
+ */
177
+ static set(name: string | string[], value?: any | any[], store?: string);
178
+ /**
179
+ * Set one or multiple values in context (asynchronous).
180
+ * @param name - Name (or array of names) to set in context
181
+ * @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.
182
+ * @param store - (optional) Name of context store
183
+ * @param callback - (optional) Callback function (`(err) => {}`)
184
+ */
185
+ static set(name: string | string[], value?: any | any[], store?: string, callback?: Function);
186
+
187
+ /** Get an array of the keys in the context store */
188
+ static keys(): Array<string>;
189
+ /** Get an array of the keys in the context store */
190
+ static keys(store: string): Array<string>;
191
+ /** Get an array of the keys in the context store */
192
+ static keys(callback: Function);
193
+ /** Get an array of the keys in the context store */
194
+ static keys(store: string, callback: Function);
195
+ }
196
+
197
+ // @ts-ignore
198
+ declare class global {
199
+ /**
200
+ * Get one or multiple values from context (synchronous).
201
+ * @param name - Name of context variable
202
+ */
203
+ static get(name: string | string[]);
204
+ /**
205
+ * Get one or multiple values from context (asynchronous).
206
+ * @param name - Name (or array of names) to get from context
207
+ * @param {function} callback - (optional) Callback function (`(err,value) => {}`)
208
+ */
209
+ static get(name: string | string[], callback: Function);
210
+ /**
211
+ * Get one or multiple values from context (synchronous).
212
+ * @param name - Name (or array of names) to get from context
213
+ * @param store - Name of context store
214
+ */
215
+ static get(name: string | string[], store: string);
216
+ /**
217
+ * Get one or multiple values from context (asynchronous).
218
+ * @param name - Name (or array of names) to get from context
219
+ * @param store - Name of context store
220
+ * @param {function} callback - (optional) Callback function (`(err,value) => {}`)
221
+ */
222
+ static get(name: string | string[], store: string, callback: Function);
223
+
224
+
225
+ /**
226
+ * Set one or multiple values in context (synchronous).
227
+ * @param name - Name (or array of names) to set in context
228
+ * @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.
229
+ */
230
+ static set(name: string | string[], value?: any | any[]);
231
+ /**
232
+ * Set one or multiple values in context (asynchronous).
233
+ * @param name - Name (or array of names) to set in context
234
+ * @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.
235
+ * @param callback - (optional) Callback function (`(err) => {}`)
236
+ */
237
+ static set(name: string | string[], value?: any | any[], callback?: Function);
238
+ /**
239
+ * Set one or multiple values in context (synchronous).
240
+ * @param name - Name (or array of names) to set in context
241
+ * @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.
242
+ * @param store - (optional) Name of context store
243
+ */
244
+ static set(name: string | string[], value?: any | any[], store?: string);
245
+ /**
246
+ * Set one or multiple values in context (asynchronous).
247
+ * @param name - Name (or array of names) to set in context
248
+ * @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.
249
+ * @param store - (optional) Name of context store
250
+ * @param callback - (optional) Callback function (`(err) => {}`)
251
+ */
252
+ static set(name: string | string[], value?: any | any[], store?: string, callback?: Function);
253
+
254
+ /** Get an array of the keys in the context store */
255
+ static keys(): Array<string>;
256
+ /** Get an array of the keys in the context store */
257
+ static keys(store: string): Array<string>;
258
+ /** Get an array of the keys in the context store */
259
+ static keys(callback: Function);
260
+ /** Get an array of the keys in the context store */
261
+ static keys(store: string, callback: Function);
262
+ }
263
+ declare class env {
264
+ /** Get an environment variable value */
265
+ static get(name:string);
266
+ }
@@ -0,0 +1,211 @@
1
+
2
+ /* NOTE: Do not edit directly! This file is generated using \`npm run update-types\` in https://github.com/Steve-Mcl/monaco-editor-esm-i18n */
3
+
4
+
5
+ /*
6
+ How to generate...
7
+ 1. Generate from packages\node_modules\@node-red\util\lib\util.js using `npx typescript` and a tsconfig.json of...
8
+ {
9
+ "files": ["packages/node_modules/@node-red/util/lib/util.js"],
10
+ "compilerOptions": {
11
+ "allowJs": true,
12
+ "declaration": true,
13
+ "emitDeclarationOnly": true,
14
+ "outDir": "types",
15
+ "strict": false,
16
+ "moduleResolution": "node"
17
+ }
18
+ }
19
+ 2. remove all the `export ` statements
20
+ 3. Wrap the remaining code in declare namespace RED { declare namespace util { ... } }
21
+ 4. check . adjust types like String --> string, Object --> object etc (where appropriate)
22
+ */
23
+
24
+ declare namespace RED {
25
+ /**
26
+ * Utility functions for the node-red function sandbox
27
+ */
28
+ namespace util {
29
+
30
+ /**
31
+ * Encode an object to JSON without losing information about non-JSON types
32
+ * such as Buffer and Function.
33
+ *
34
+ * *This function is closely tied to its reverse within the editor*
35
+ *
36
+ * @param {Object} msg
37
+ * @param {Object} opts
38
+ * @return {Object} the encoded object
39
+ * @memberof @node-red/util_util
40
+ */
41
+ function encodeObject(msg: any, opts: any): any;
42
+ /**
43
+ * Converts the provided argument to a String, using type-dependent
44
+ * methods.
45
+ *
46
+ * @param {any} o - the property to convert to a String
47
+ * @return {string} the stringified version
48
+ * @memberof @node-red/util_util
49
+ */
50
+ function ensureString(o: any): string;
51
+ /**
52
+ * Converts the provided argument to a Buffer, using type-dependent
53
+ * methods.
54
+ *
55
+ * @param {any} o - the property to convert to a Buffer
56
+ * @return {string} the Buffer version
57
+ * @memberof @node-red/util_util
58
+ */
59
+ function ensureBuffer(o: any): string;
60
+ /**
61
+ * Safely clones a message object. This handles msg.req/msg.res objects that must
62
+ * not be cloned.
63
+ *
64
+ * @param {object} msg - the message object to clone
65
+ * @return {object} the cloned message
66
+ * @memberof @node-red/util_util
67
+ */
68
+ function cloneMessage(msg: object): object;
69
+ /**
70
+ * Compares two objects, handling various JavaScript types.
71
+ *
72
+ * @param {any} obj1
73
+ * @param {any} obj2
74
+ * @return {boolean} whether the two objects are the same
75
+ * @memberof @node-red/util_util
76
+ */
77
+ function compareObjects(obj1: any, obj2: any): boolean;
78
+ /**
79
+ * Generates a psuedo-unique-random id.
80
+ * @return {string} a random-ish id
81
+ * @memberof @node-red/util_util
82
+ */
83
+ function generateId(): string;
84
+ /**
85
+ * Gets a property of a message object.
86
+ *
87
+ * Unlike {@link @node-red/util-util.getObjectProperty}, this function will strip `msg.` from the
88
+ * front of the property expression if present.
89
+ *
90
+ * @param {object} msg - the message object
91
+ * @param {string} expr - the property expression
92
+ * @return {any} the message property, or undefined if it does not exist
93
+ * @throws Will throw an error if the *parent* of the property does not exist
94
+ * @memberof @node-red/util_util
95
+ */
96
+ function getMessageProperty(msg: object, expr: string): any;
97
+ /**
98
+ * Sets a property of a message object.
99
+ *
100
+ * Unlike {@link @node-red/util-util.setObjectProperty}, this function will strip `msg.` from the
101
+ * front of the property expression if present.
102
+ *
103
+ * @param {object} msg - the message object
104
+ * @param {string} prop - the property expression
105
+ * @param {any} [value] - the value to set
106
+ * @param {boolean} [createMissing] - whether to create missing parent properties
107
+ * @memberof @node-red/util_util
108
+ */
109
+ function setMessageProperty(msg: object, prop: string, value?: any, createMissing?: boolean): boolean;
110
+ /**
111
+ * Gets a property of an object.
112
+ *
113
+ * Given the object:
114
+ *
115
+ * {
116
+ * "pet": {
117
+ * "type": "cat"
118
+ * }
119
+ * }
120
+ *
121
+ * - `pet.type` will return `"cat"`.
122
+ * - `pet.name` will return `undefined`
123
+ * - `car` will return `undefined`
124
+ * - `car.type` will throw an Error (as `car` does not exist)
125
+ *
126
+ * @param {object} msg - the object
127
+ * @param {string} expr - the property expression
128
+ * @return {any} the object property, or undefined if it does not exist
129
+ * @throws Will throw an error if the *parent* of the property does not exist
130
+ * @memberof @node-red/util_util
131
+ */
132
+ function getObjectProperty(msg: object, expr: string): any;
133
+ /**
134
+ * Sets a property of an object.
135
+ *
136
+ * @param {object} msg - the object
137
+ * @param {string} prop - the property expression
138
+ * @param {any} [value] - the value to set
139
+ * @param {boolean} [createMissing] - whether to create missing parent properties
140
+ * @memberof @node-red/util_util
141
+ */
142
+ function setObjectProperty(msg: object, prop: string, value?: any, createMissing?: boolean): boolean;
143
+ /**
144
+ * Evaluates a property value according to its type.
145
+ *
146
+ * @param {string} value - the raw value
147
+ * @param {string} type - the type of the value
148
+ * @param {Node} node - the node evaluating the property
149
+ * @param {Object} msg - the message object to evaluate against
150
+ * @param {Function} callback - (optional) called when the property is evaluated
151
+ * @return {any} The evaluated property, if no `callback` is provided
152
+ * @memberof @node-red/util_util
153
+ */
154
+ function evaluateNodeProperty(value: string, type: string, node: Node, msg: any, callback: Function): any;
155
+ /**
156
+ * Parses a property expression, such as `msg.foo.bar[3]` to validate it
157
+ * and convert it to a canonical version expressed as an Array of property
158
+ * names.
159
+ *
160
+ * For example, `a["b"].c` returns `['a','b','c']`
161
+ *
162
+ * @param {string} str - the property expression
163
+ * @return {any[]} the normalised expression
164
+ * @memberof @node-red/util_util
165
+ */
166
+ function normalisePropertyExpression(str: string): any[];
167
+ /**
168
+ * Normalise a node type name to camel case.
169
+ *
170
+ * For example: `a-random node type` will normalise to `aRandomNodeType`
171
+ *
172
+ * @param {string} name - the node type
173
+ * @return {string} The normalised name
174
+ * @memberof @node-red/util_util
175
+ */
176
+ function normaliseNodeTypeName(name: string): string;
177
+ /**
178
+ * Prepares a JSONata expression for evaluation.
179
+ * This attaches Node-RED specific functions to the expression.
180
+ *
181
+ * @param {string} value - the JSONata expression
182
+ * @param {Node} node - the node evaluating the property
183
+ * @return {any} The JSONata expression that can be evaluated
184
+ * @memberof @node-red/util_util
185
+ */
186
+ function prepareJSONataExpression(value: string, node: Node): any;
187
+ /**
188
+ * Evaluates a JSONata expression.
189
+ * The expression must have been prepared with {@link @node-red/util-util.prepareJSONataExpression}
190
+ * before passing to this function.
191
+ *
192
+ * @param {Object} expr - the prepared JSONata expression
193
+ * @param {Object} msg - the message object to evaluate against
194
+ * @param {Function} callback - (optional) called when the expression is evaluated
195
+ * @return {any} If no callback was provided, the result of the expression
196
+ * @memberof @node-red/util_util
197
+ */
198
+ function evaluateJSONataExpression(expr: any, msg: any, callback: Function): any;
199
+ /**
200
+ * Parses a context property string, as generated by the TypedInput, to extract
201
+ * the store name if present.
202
+ *
203
+ * For example, `#:(file)::foo` results in ` { store: "file", key: "foo" }`.
204
+ *
205
+ * @param {string} key - the context property string to parse
206
+ * @return {any} The parsed property
207
+ * @memberof @node-red/util_util
208
+ */
209
+ function parseContextStore(key: string): any;
210
+ }
211
+ }