-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathx.json
519 lines (519 loc) · 14.5 KB
/
x.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
{
"name": "utils",
"description": "Utility components for Chiχ",
"version": "0.0.3",
"repository": {
"type": "git",
"url": "https://github.com/nodule/utils.git"
},
"dependencies": {
"JSONPath": "0.x.x",
"csv": "0.x.x",
"glob": "3.x.x",
"iffi": "0.x.x",
"inquiry": "0.x.x",
"json-path": "0.x.x",
"xml2js": "0.x.x",
"xml2json": "0.x.x"
},
"nodes": [
{
"name": "converter",
"ns": "utils",
"description": "Convert ascii, utf8, ucs2, base64, binary or hex",
"async": true,
"phrases": {
"active": "Converting from {{input.from}} to {{input.to}}"
},
"ports": {
"input": {
"in": {
"type": "any",
"title": "Input",
"async": true
},
"from": {
"enum": [
"ascii",
"utf8",
"ucs2",
"base64",
"binary",
"hex"
],
"type": "string",
"title": "From",
"default": "utf8"
},
"to": {
"enum": [
"ascii",
"utf8",
"ucs2",
"base64",
"binary",
"hex"
],
"type": "string",
"title": "To",
"default": "utf8"
}
},
"output": {
"out": {
"type": "any",
"title": "Output"
}
}
},
"dependencies": {
"npm": {
"buffer": "internal"
}
},
"fn": "on.input.in = function() {\n // \\n replace shouldn't be necessary.\n if(typeof $.in === 'string' && $.from === 'base64') {\n $.in = $.in.replace('\\n', '');\n }\n var d = new buffer.Buffer($.in, $.from);\n output( { out: $.write('in', d.toString($.to)) });\n};\n"
},
{
"name": "csv",
"ns": "utils",
"title": "CSV",
"async": true,
"description": "NodeCSV Parser",
"phrases": {
"active": "Parsing CSV"
},
"ports": {
"input": {
"in": {
"type": "string",
"title": "CSV",
"async": true,
"description": "A Comma Seperated Values document",
"required": true
}
},
"output": {
"out": {
"type": "array",
"title": "Output",
"description": "An array of records"
}
}
},
"dependencies": {
"npm": {
"csv": "0.x.x"
}
},
"fn": "on.input.in = function() {\n csv().\n from.\n string($.in, {}).\n to.\n array(function(val) {\n output({ out: $.write('in', val) });\n });\n};\n"
},
{
"name": "dummy",
"ns": "utils",
"title": "Dummy",
"description": "Takes an input and passes it to output.",
"phrases": {
"active": "Dummy"
},
"ports": {
"input": {
"in": {
"type": "any",
"title": "Input"
}
},
"output": {
"out": {
"type": "any",
"title": "Output"
}
}
},
"fn": "output.out = $.get('in')\n"
},
{
"name": "exec",
"ns": "utils",
"description": "Execute a program",
"phrases": {
"active": "Executing {{input.in}}"
},
"ports": {
"input": {
"in": {
"type": "string",
"title": "Program String",
"description": "e.g. `cat *.js bad_file | wc -l`"
},
"data": {
"type": "string",
"title": "Data For StdIn",
"description": "Optional data to be send to stdin, the process executed must be set to expect stdin",
"default": null
},
"encoding": {
"type": "string",
"title": "Encoding",
"default": "utf-8"
},
"timeout": {
"type": "number",
"title": "Encoding",
"default": 0
},
"maxBuffer": {
"type": "number",
"title": "Buffer Maximum",
"default": 204800
},
"killSignal": {
"type": "string",
"title": "Kill Signal",
"default": "SIGTERM"
},
"cwd": {
"type": "string",
"title": "Current working dir",
"default": null
},
"env": {
"type": "string",
"title": "Env",
"default": null
}
},
"output": {
"out": {
"title": "Std Out",
"type": "string"
},
"flushed": {
"title": "Flushed",
"type": "boolean"
},
"error": {
"title": "Error",
"type": "object"
}
}
},
"dependencies": {
"npm": {
"child_process": "builtin"
}
},
"fn": "output = function (cb) {\n var child = child_process.exec($.in,\n function (error, stdout, stderr) {\n\n if(stderr) {\n cb({error: $.create(stderr)});\n } else if (error) {\n cb({error: $.create(error)});\n } else {\n cb({out: $.create(stdout)});\n }\n\n done();\n }, {\n encoding: $.encoding,\n maxBuffer: $.maxBuffer,\n killSignal: $.killSignal,\n cwd: $.cwd,\n env: $.env\n });\n\n child.on('error', function(err) {\n cb({ error: $.create(err) });\n });\n\n if ($.data) {\n child.stdin.end($.data, $.encoding, function () {\n cb({flushed: $.create(true)});\n });\n }\n};\n"
},
{
"name": "function",
"ns": "utils",
"async": true,
"description": "Execute a function",
"phrases": {
"active": "Executing Function "
},
"ports": {
"input": {
"in": {
"type": "any",
"async": true,
"title": "Function Input"
},
"fn": {
"type": "function",
"args": [
"data",
"output",
"$"
],
"title": "Function Body"
}
},
"output": {
"out": {
"title": "Std Out",
"type": "string"
},
"error": {
"title": "Error",
"type": "object"
}
}
},
"fn": "on.input.in = function() {\n $.fn($.in, output, $);\n}\n"
},
{
"name": "if",
"ns": "utils",
"title": "IF",
"description": "Accepts a value on one port and checks it against an if statement.",
"phrases": {
"active": "Deciding IF"
},
"ports": {
"input": {
"value": {
"type": "any",
"title": "Value"
},
"in": {
"type": "string",
"title": "IF statement",
"description": "Any if statement, the input is available as `in`. e.g. in.required === true, providing the input object has a property `required`, compilation failures will go to the error port. The input value will be passed either to the Yes or No port."
}
},
"output": {
"error": {
"type": "object",
"title": "Error",
"description": "Error"
},
"yes": {
"type": "any",
"title": "Yes"
},
"no": {
"type": "any",
"title": "No"
}
}
},
"dependencies": {
"npm": {
"iffi": "0.x.x"
}
},
"fn": "try {\n if (iffi($.in, {\n value: $.value\n })) {\n output = {yes: $.create($.value)};\n } else {\n output = {no: $.create($.value)};\n }\n} catch (e) {\n output = {error: $.create(e)};\n}\n"
},
{
"name": "if2",
"ns": "utils",
"title": "IF2",
"description": "Accepts values on two ports and checks it against an if statement.",
"phrases": {
"active": "Deciding IF"
},
"ports": {
"input": {
"value": {
"type": "any",
"title": "Input Value",
"description": "The value to be checked"
},
"compare": {
"type": "any",
"title": "Comparant Value"
},
"in": {
"type": "string",
"title": "IF statement",
"description": "Any if statement, the input is available as `in`. e.g. in.required === true, providing the input object has a property `required`, compilation failures will go to the output port."
}
},
"output": {
"error": {
"type": "object",
"title": "Error",
"description": "Error"
},
"yes": {
"type": "boolean",
"title": "Yes"
},
"no": {
"type": "boolean",
"title": "No"
}
}
},
"dependencies": {
"npm": {
"iffi": "0.x.x"
}
},
"fn": "try {\n if (iffi($.in, {\n 'value': $.value,\n 'compare': $.compare\n })) {\n output = {yes: $.create($.value)};\n } else {\n output = {no: $.create($.value)};\n }\n} catch (e) {\n output = {error: $.create(e)};\n}\n"
},
{
"name": "interval",
"ns": "utils",
"async": true,
"description": "Repeats the input",
"phrases": {
"active": "Repeating input every {{input.interval}} milliseconds."
},
"expose": [
"setInterval"
],
"ports": {
"input": {
"in": {
"type": "any",
"title": "Input",
"async": true,
"description": "Input to be repeated (if any)",
"default": null
},
"interval": {
"type": "number",
"title": "Interval",
"description": "Interval in milliseconds",
"format": "time",
"required": true
},
"stop": {
"type": "any",
"title": "Stop",
"async": true
},
"start": {
"type": "any",
"title": "Start",
"async": true
}
},
"output": {
"out": {
"type": "any",
"title": "Output",
"description": "Outputs the repeated input"
}
}
},
"fn": "state.doInterval = function() {\n state.timer = setInterval(function () {\n output({out: state.data});\n }, state.interval);\n};\n\non.input.in = function() {\n // automatically picked up by interval\n state.data = $.get('in');\n};\n\non.input.interval = function() {\n state.interval = $.interval;\n\n if(state.timer) {\n // already running reset\n clearInterval(state.timer);\n }\n\n state.doInterval();\n};\n\non.input.start = function() {\n // reject start if no data yet\n if(undefined === state.data) {\n return false;\n }\n\n // reject start if no interval value yet\n if(undefined === state.interval) {\n return false;\n }\n\n if(!state.timer) {\n state.doInterval();\n }\n};\n\non.input.stop = function() {\n if(state.timer) {\n clearInterval(state.timer);\n }\n};\n"
},
{
"name": "method",
"ns": "utils",
"description": "Execute a method",
"phrases": {
"active": "Executing method {{input.method}}"
},
"ports": {
"input": {
"in": {
"type": "array",
"title": "Arguments",
"description": "arguments to be applied to this method",
"default": []
},
"instance": {
"type": "function",
"title": "Instance",
"description": "instance to invoke this method on"
},
"method": {
"type": "string",
"title": "Method name"
}
},
"output": {
"out": {
"title": "Out",
"type": "any"
},
"error": {
"title": "Error",
"type": "object"
}
}
},
"fn": "output.out = $.write('in', $.instance[$.method].apply($.instance, $.in))\n"
},
{
"name": "true",
"title": "true?",
"ns": "utils",
"description": "Whether the input is true or false",
"phrases": {
"active": "Determining truth"
},
"ports": {
"input": {
"in": {
"type": "boolean",
"title": "A boolean"
}
},
"output": {
"yes": {
"type": "boolean",
"title": "Yes"
},
"no": {
"type": "boolean",
"title": "No"
}
}
},
"fn": "if (!!$.in) {\n output.yes = $.get('in')\n} else {\n output.no = $.get('in')\n}\n"
},
{
"name": "wait",
"ns": "utils",
"async": true,
"description": "Holds the input for a while",
"phrases": {
"active": "Holding input for {{input.timeout}} milliseconds."
},
"expose": [
"setTimeout"
],
"ports": {
"input": {
"in": {
"type": "any",
"title": "Input",
"description": "Input to be delayed",
"async": true
},
"timeout": {
"type": "number",
"title": "Timeout",
"description": "Timeout in milliseconds",
"format": "time"
}
},
"output": {
"out": {
"type": "any",
"title": "Output",
"description": "Outputs the delayed input"
}
}
},
"fn": "on.input.in = function() {\n setTimeout(function () {\n output({out: $.get('in')});\n }, $.timeout);\n};\n"
},
{
"name": "xml2js",
"ns": "utils",
"description": "Simple XML to JavaScript object converter",
"phrases": {
"active": "Converting XML to Object"
},
"ports": {
"input": {
"xml": {
"type": "string",
"format": "xml",
"title": "XML"
}
},
"output": {
"error": {
"type": "object",
"title": "Error Object"
},
"result": {
"type": "object"
}
}
},
"dependencies": {
"npm": {
"xml2js": "0.x.x"
}
},
"fn": "output = [xml2js, 'parseString', $.xml]\n"
}
]
}